Skip to content

PX to REM converter

Convert px to rem at any root font size, rewrite every px in a pasted stylesheet at once, and keep a permanent 1–96 px reference table to hand.

  • Runs in your browser
  • Nothing you enter is sent
  • Free, no account
Pixels (px) to Root em (rem)
Convert a single value, or paste a whole stylesheet and rewrite every length at once. The root and parent font sizes below drive every number on this page.

A CSS pixel — an absolute unit in CSS terms, independent of the device pixel ratio.

Relative to the root element's font size, which the browser defaults to 16 px.

The rem basis. 16 px unless you changed the html font-size.

The em and % basis — the computed font size of the element's parent.

16px equals
1rem
At a 16 px root and a 16 px parent.
px
16
rem
1
em
1
pt
12
%
100
rem = px ÷ root font size (16 px)
1rem = 16 px ÷ 16
(via 16 px)
The conversion with your own numbers substituted in.
Bulk rewrite a stylesheet
Paste CSS and every matching length is converted at once. Strings, comments and url() bodies are copied through untouched, and each category of value can be left alone.
Reference table
Every common size at a 16 px root font size. Change the root above and the whole table re-computes.
Pixel values converted to rem, em, points and percent
pxremempt%
1px0.0625rem0.0625em0.75pt6.25%
2px0.125rem0.125em1.5pt12.5%
4px0.25rem0.25em3pt25%
6px0.375rem0.375em4.5pt37.5%
8px0.5rem0.5em6pt50%
10px0.625rem0.625em7.5pt62.5%
11px0.6875rem0.6875em8.25pt68.75%
12px0.75rem0.75em9pt75%
13px0.8125rem0.8125em9.75pt81.25%
14px0.875rem0.875em10.5pt87.5%
15px0.9375rem0.9375em11.25pt93.75%
16px1rem1em12pt100%
17px1.0625rem1.0625em12.75pt106.25%
18px1.125rem1.125em13.5pt112.5%
20px1.25rem1.25em15pt125%
22px1.375rem1.375em16.5pt137.5%
24px1.5rem1.5em18pt150%
26px1.625rem1.625em19.5pt162.5%
28px1.75rem1.75em21pt175%
30px1.875rem1.875em22.5pt187.5%
32px2rem2em24pt200%
36px2.25rem2.25em27pt225%
40px2.5rem2.5em30pt250%
44px2.75rem2.75em33pt275%
48px3rem3em36pt300%
56px3.5rem3.5em42pt350%
64px4rem4em48pt400%
72px4.5rem4.5em54pt450%
80px5rem5em60pt500%
96px6rem6em72pt600%
Your CSS never leaves this tab — check it yourself—

Starting the network probe…

The counter above wraps fetch, XMLHttpRequest and navigator.sendBeacon in this tab and counts every call. It does not block anything — it just reports.

Two ways to verify independently

  1. Turn off Wi-Fi or enable airplane mode, then use the tool. It keeps working, because the page is already fully loaded.
  2. Open your browser devtools, switch to the Network tab, clear it, and run the tool. No new row appears.

Why this matters

In 2025 researchers found that popular online formatters had retained tens of thousands of user-submitted snippets — JSONFormatter.org and CodeBeautify together exposed roughly 80,000 saved documents, many containing live cloud credentials, private keys and internal database connection strings, because “format this” quietly meant “upload this”. A separate incident exposed roughly 3.5 million user PDFs on a document-conversion service. The only structural fix is not sending the data in the first place: this site is served under a Content-Security-Policy whose connect-src contains no third-party origin, so a request off this device cannot be made even by accident.

The formula

rem = px ÷ root font size

At the 16px browser default:
  24px ÷ 16 = 1.5rem
  14px ÷ 16 = 0.875rem
  10px ÷ 16 = 0.625rem

The root font size is whatever html computes to. Leave it at 16 unless your project changes it — and if it does, set the field above and every number on this page, including the reference table, recomputes.

The accessibility argument, stated plainly

A visitor who has set their browser’s default text size to 20px has done so because 16px is hard for them to read. If your type is in px, nothing changes for them: 14px stays 14px. If it is in rem, the entire interface scales proportionally and the site becomes usable.

Page zoom is not the same thing. Zoom scales everything including the layout, which on a laptop means horizontal scrolling; text-size preference scales the text within the layout. Browsers offer both because they solve different problems, and only one of them is defeated by px.

This is also the reason to avoid px in media queries. A breakpoint at 768px fires at the same viewport width regardless of text size, so a user with large text hits the desktop layout while their content is still overflowing.

What to use where

PropertyUnitWhy
font-sizeremRespects the user’s preference; no compounding
margin, padding, gapremSpacing should grow with type or the rhythm breaks
border-radiusrem, or px for small valuesA 2px radius does not need to scale
border-width, outline-widthpxA hairline should stay a hairline
Breakpointsrem or emLayout should respond to text size, not just viewport width
max-width for readable textchMeasure is about characters per line, roughly 60–75ch
Component-internal spacingemScales with the component’s own font size — see px to em

The bulk rewrite, and what it deliberately skips

Paste a whole stylesheet and every matching length is converted at once. The scanner is string-, comment- and url()-aware, so content: "16px" and url(sprite-32px.png) are copied through untouched. Three categories are skipped by default, each with its own switch:

  • Zero. 0rem is noise; 0 is the same length in every unit.
  • 1px and 2px. Almost always a hairline border, outline or shadow spread. Converting them to 0.0625rem makes them scale, and a scaled hairline renders as a blurry 1.3px line at some zoom levels.
  • Media query preludes. Converting a breakpoint changes when it fires, which is a design decision rather than a mechanical one. Do it deliberately.

There is also a property filter: enter font-size, line-height and only those declarations are touched, which is the safest way to migrate an existing codebase incrementally.

The 62.5% trick, and the case against it

Setting html { font-size: 62.5% } makes 1rem equal 10px, so 1.4rem is 14px and the arithmetic disappears. It is widely used and it has a real cost: it changes the default text size for every visitor who has not overridden it, and you then have to set the body back to 1.6rem to compensate. It also breaks the direct correspondence between the user’s chosen size and what they get.

If your project uses it, set the root field above to 10 and this page will match. If you are starting fresh, leave the root at 16, use the reference table, and let the build handle the division.

Questions

What is the formula?

rem = px ÷ root font size. With the browser default of 16 px, 24 px is 1.5 rem and 14 px is 0.875 rem. The page shows the division with your own numbers substituted, so you can check it rather than trust it.

Why use rem instead of px?

Because rem respects the visitor's browser font-size setting and px does not. Someone who has set their default to 20 px because they cannot comfortably read 16 px gets a proportionally larger interface — which is the single highest-impact accessibility change most sites can make.

What does the bulk rewrite skip, and why?

By default: zero values, because `0rem` is noise; 1–2 px values, because they are usually hairline borders that should stay crisp at any zoom; and anything inside a `@media` prelude, because breakpoints in rem behave differently from breakpoints in px. Each of those is a switch. Strings, comments and `url()` contents are never touched at all.

Should I set html { font-size: 62.5% } to make 1 rem = 10 px?

It makes the arithmetic easier and it is a widely used trick, but it changes the default text size for anyone who has not overridden it and it breaks the correspondence with the user's chosen size. Set the root font size field to 10 here if your project uses it; otherwise leave it at 16.

Is rem right for everything?

No. Use rem for type, spacing and radii. Use px for hairline borders and for things that genuinely should not scale. Use ch or ex for measure. Use % or fr for layout that must fill its container.