PX to REM converter

Convert pixels to rem and rem to pixels at any root font size, or convert a whole stylesheet at once. Free, no sign-up, and everything runs in your browser.

The font size of the html element. Browsers use 16px unless the page or the user changes it.

24px = 1.5rem at a 16px root font size.

Convert a whole stylesheet

Paste CSS, SCSS or a list of values. Every value with the unit is converted; names like icon-16px.png stay as they are.

9 values converted
.card {
  padding: 1.5rem 2rem;
  margin-bottom: 2.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
}

.card h2 {
  font-size: 1.75rem;
  line-height: 2.25rem;
  margin: 0 0 0.5rem;
}

@media (min-width: 48rem) {
  .card { padding: 3rem; }
}

px to rem table 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
24px1.5rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
44px2.75rem
48px3rem
56px3.5rem
64px4rem
72px4.5rem
80px5rem
96px6rem
128px8rem

What this px to rem converter does

This tool converts pixels to rem and rem back to pixels at any root font size. Type in either field and the other one updates at once. Below it, you can paste a whole stylesheet and convert every px value to rem (or every rem value to px) in one step, and a table shows the common sizes at your root font size.

One rem is the font size of the root element, which is normally the <html> element.1 Browsers start at a font size of 16px, so 1rem is 16px unless the page or the person reading it changes that. The math is simple:

  • px to rem: rem = px ÷ root font size. At 16px, 24px is 24 ÷ 16 = 1.5rem.
  • rem to px: px = rem × root font size. At 16px, 0.875rem is 14px.

Everything runs in your browser. Nothing you type or paste is sent anywhere.

How to use it

  1. Leave Root font size at 16 unless your CSS sets a different size on html. If your stylesheet has html { font-size: 62.5%; }, the root is 10px, so enter 10.
  2. Type a value in Pixels or REM. You can paste values with the unit, like 24px or 1.5rem. Use the copy icon in the field to copy the value with its unit.
  3. To convert a file, paste it under Convert a whole stylesheet, choose px to rem or rem to px, and select Copy CSS. Values inside names, such as icon-16px.png or a .w-2rem class, are left alone. Run the result through the CSS formatter if you also want it tidy or minified.

Values in @media conditions are always converted at 16px, because media queries ignore the font size your CSS sets on html (see the FAQ below). By default, values of 1px and less stay in px. Hairline borders and outlines usually should not grow when someone picks a larger font, and 1px at a 16px root would become 0.0625rem, which is hard to read in code.

Why use rem instead of px?

People can set a larger default font size in their browser. Sizes in rem follow that setting, and sizes in px do not. MDN says it is best to use values relative to the user's default font size, and that px font sizes are not accessible because some browsers then can't change them.2 WCAG success criterion 1.4.4 (level AA) asks that text can be resized up to 200 percent without assistive technology and without losing content or functionality.3 Font sizes, spacing around text and breakpoints in rem make that much easier to pass.

Pixels are still the right unit for some things: borders, shadows, and images that must stay sharp at an exact size. A CSS pixel is not a screen pixel; it is defined as 1/96 of an inch, so it already scales with screen density.1

A clean landing page that still reads well at 200% zoom is a small thing that makes a product feel finished on launch day.

Frequently asked questions

Sources

  1. MDN Web Docs: <length> CSS type (rem, em and px)

  2. MDN Web Docs: font-size (accessibility of relative sizes)

  3. W3C WAI: Understanding Success Criterion 1.4.4: Resize Text

  4. W3C: Media Queries Level 4 (units in media queries)

  5. W3C: CSS Values and Units Module Level 4 (font-relative lengths)