📐 PX to REM Converter

Convert px to rem and rem to px at any root font size, or paste a whole stylesheet to convert every value at once. Includes a px-to-rem table.

✓ Free✓ No Signup Required✓ Browser-Based

Browsers default to a 16px root font size. Change it only if your CSS sets a different size on the html element.

24px = 1.5rem

Bulk convert CSS

px to rem table (root 16px)

pxremTailwind spacing
1px0.0625rem—
2px0.125rem0.5
4px0.25rem1
6px0.375rem1.5
8px0.5rem2
10px0.625rem2.5
12px0.75rem3
13px0.8125rem—
14px0.875rem3.5
15px0.9375rem—
16px1rem4
18px1.125rem—
20px1.25rem5
22px1.375rem—
24px1.5rem6
28px1.75rem7
30px1.875rem—
32px2rem8
36px2.25rem9
40px2.5rem10
48px3rem12
56px3.5rem14
60px3.75rem—
64px4rem16
72px4.5rem—
80px5rem20
96px6rem24
128px8rem32

Tailwind’s default spacing unit is 0.25rem, so at a 16px root, p-4 = 1rem = 16px.

What PX to REM Converter Does

This px to rem converter changes pixel values into rem units and back. Type a value in either box and the other updates as you type, at the browser’s default root size of 16px or any root font size your site uses. A reference table lists common sizes from 1px to 128px, with the matching Tailwind spacing step where there is one.

For existing projects, paste a stylesheet into the bulk converter and every px value becomes rem — or every rem becomes px — in one pass. One-pixel borders are kept as px by default, @media conditions are left alone because they do not follow the root font size, and you choose the number of decimal places. Nothing is uploaded; the conversion happens in your browser.

How to Use PX to REM Converter

  1. Enter your root font size — 16px is the browser default
  2. Type a px value to get rem, or a rem value to get px
  3. Paste a stylesheet into the bulk converter to convert every value
  4. Choose which small values to keep as px and how many decimals to use
  5. Copy the converted CSS

Formula Used by PX to REM Converter

Converting between px and rem

rem = px ÷ root font size · px = rem × root font size

Worked example

18px at a 16px root, and at a 10px root (html { font-size: 62.5% }).

  1. 18 ÷ 16 = 1.125rem
  2. 18 ÷ 10 = 1.8rem

Result: The same design size needs a different rem value when the root size changes.

Why em compounds

em = px ÷ the element’s own font size (for font-size, the parent’s)

Worked example

A 16px page with a list inside a list, both set to font-size: 1.5em.

  1. Outer list: 1.5 × 16 = 24px
  2. Inner list: 1.5 × 24 = 36px
  3. With 1.5rem, both would be 24px

Result: rem stays predictable when elements are nested.

rem at Different Root Sizes

px16px root10px root18px root
12px0.75rem1.2rem0.6667rem
14px0.875rem1.4rem0.7778rem
16px1rem1.6rem0.8889rem
18px1.125rem1.8rem1rem
20px1.25rem2rem1.1111rem
24px1.5rem2.4rem1.3333rem
32px2rem3.2rem1.7778rem
48px3rem4.8rem2.6667rem

CSS Length Units Compared

UnitRelative toGood for
pxA fixed CSS pixelBorders and fine details
remThe root (html) font sizeFont sizes, spacing and layout
emThe element’s own font sizePadding that scales with a button’s text
%The parent elementWidths in fluid layouts
vw / vh1% of the viewport width / heightFull-screen sections, fluid type
chWidth of the “0” characterReadable line lengths, such as max-width: 65ch

How to Read Your Result

rem and accessibility

Many people raise their browser’s default font size instead of zooming. Text sized in rem grows with that setting, while text sized in px does not. Using rem for font sizes, and often for spacing, respects that preference and makes the WCAG requirement that text can be resized to 200% easier to meet.

Converting a legacy stylesheet

Convert in one pass, then review the result: keep hairlines and shadows in px, check values used inside calc(), and test the page at a larger browser font size. Media query conditions are skipped by default; convert breakpoints to em deliberately if you want them to follow the user’s font size.

How many decimals?

Four decimal places is plenty: 0.0001rem is less than a hundredth of a pixel at a 16px root. Browsers snap to device pixels anyway, so 0.8125rem and 0.813rem render identically.

Limitations & Accuracy Notes

  • Every number followed by px is converted, including any inside comments or url() paths — review the output before using it.
  • Unitless numbers in CSS-in-JS style objects are not detected.
  • Only @media conditions are skipped; @container and @supports conditions are converted like ordinary CSS.

Frequently Asked Questions

How do you convert px to rem?
Divide the pixel value by the root font size. With the usual browser default of 16px, 24px = 24 ÷ 16 = 1.5rem and 12px = 0.75rem. To go back, multiply rem by the root size.
How many pixels is 1rem?
1rem equals the font size of the root html element. Browsers default to 16px, so 1rem is usually 16px — unless your CSS sets a different root size or the user has changed the default font size in their browser.
What is the difference between rem and em?
rem is relative to the root element’s font size, so it means the same everywhere on the page. em is relative to the current element’s font size (or its parent’s, for font-size itself), so em values compound when elements are nested.
Why use rem instead of px?
Sizes in rem follow the user’s preferred browser font size, so text and spacing grow for people who set larger text. Font sizes in px ignore that setting (though page zoom still works), which is why rem is the usual choice for accessible typography.
Should I convert 1px borders to rem?
Usually not. Hairline borders and fine details tend to look best at exactly 1px, and a rem value could round to a blurry fraction of a pixel. The bulk converter leaves values of 1px and below unchanged by default.
What does html { font-size: 62.5% } do?
It sets the root size to 10px (62.5% of 16px), so 1.6rem = 16px and conversions become easy mental math. It still respects user settings, but you must set body text back to 1.6rem. Enter 10 as the root size here if you use it.
Do rem values in media queries use the root font size?
No. In media query conditions, rem and em are based on the browser’s initial font size, not the font size set on the html element. That is why the bulk converter leaves @media conditions alone unless you choose otherwise.
By OnlineToolHubs Team • Updated September 2026