All tools

PX to REM converter

Convert px to rem and back, or a whole stylesheet.

Convert a value

1rem = 16px · 24px = 1.5rem

Common sizes at 16px

PixelsREM
1px0.0625rem
2px0.125rem
4px0.25rem
6px0.375rem
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
15px0.9375rem
16px1rem
18px1.125rem
20px1.25rem
22px1.375rem
24px1.5rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
48px3rem
56px3.5rem
64px4rem
72px4.5rem
80px5rem
96px6rem
128px8rem

Convert a whole stylesheet

Direction
Converted (8 values)
.card {
  padding: 1.5rem 2rem;
  margin-bottom: -0.5rem;
  border: 1px solid #dde3d9;
  border-radius: 0.75rem;
  font-size: 1.125rem;
  line-height: 1.75rem;
  background: url("icons/arrow-16px.svg");
}

@media (min-width: 48rem) {
  .card { max-width: 40rem; }
}

About the PX to REM converter

rem is a CSS unit relative to the root font size, which is 16px by default. Using rem for font sizes and spacing means your layout scales when someone increases the default text size in their browser, which pixel values ignore.

This converter changes px to rem and rem to px using any root font size, shows a table of common sizes, and can convert every pixel value in a whole stylesheet at once.

How to use the PX to REM converter

  1. Enter a value in Pixels or REM; the other box updates as you type.
  2. Change Root font size if your site sets a different size on the html element.
  3. To convert a file, paste your CSS into Your CSS and choose the direction.
  4. Click Copy CSS to copy the converted stylesheet.

Example

Convert a stylesheet with a 16px root

Input

.card {
  padding: 24px 32px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
}

Output

.card {
  padding: 1.5rem 2rem;
  font-size: 0.875rem;
  border: 1px solid #ddd;
  border-radius: 0.75rem;
}

1px borders stay 1px, so hairlines don't vanish when rem values round down.

Common errors and how to fix them

rem sizes don't match the design

The root font size isn't 16px. Check html { font-size } in your CSS; with 62.5% (10px), 24px is 2.4rem, not 1.5rem. Set the root size in the converter to match.

Nested text gets smaller and smaller

That's em, which compounds with each nested element. rem is always relative to the root element, so it doesn't compound.

Should media queries use rem?

Media queries in em or rem both use the browser's default size, not your html font size. em is the common choice, and it respects a user's zoom setting.

Good to know

  • rem = px ÷ root font size. At the default 16px, 24px is 1.5rem and 1rem is 16px. Results are rounded to at most 4 decimal places.
  • Keep 1px values leaves 1px borders and hairlines alone, since they're meant to stay one device-independent pixel.
  • Values inside comments, quoted strings and url(), and names like icon-16px.svg, are left unchanged. 0px is kept as written.
  • Media queries can use rem too. Browsers treat rem in media queries as the default font size (usually 16px), regardless of the root font size you set in CSS.
  • em is similar but relative to the parent element's font size, so it compounds when elements are nested. rem always refers to the root, which makes it more predictable.

Frequently asked questions

How many pixels is 1rem?

1rem equals the root (html) font size, which is 16px in every major browser by default. If you set html { font-size: 62.5%; }, 1rem becomes 10px; change Root font size to 10 to convert for that setup.

Should I use rem or px?

Use rem for font sizes, and usually for spacing and layout widths, so the design respects people's text size settings. px is fine for borders, shadows and other small details that shouldn't scale.

What's the difference between rem and em?

rem is relative to the root font size, so it's the same everywhere on the page. em is relative to the current element's font size, so a nested element with 1.2em inside another 1.2em ends up 1.44 times larger.