CSS Unit Converter

PX to REM Converter

Convert px to rem (and rem back to px) with a live, bidirectional calculator. Set a custom root font size, batch-convert a whole stylesheet's worth of values at once, and copy clean CSS output — all client-side, nothing leaves your browser.

Scale preview 16px = 1rem

Bold ticks mark every root-font-size interval (currently 16px). The dot tracks the value in the converter below.

px
rem
px
/* generated by mockuptemplate.net */
.element {
  font-size: 1rem; /* 16px */
}
Recent conversions
Your last few conversions will appear here.
PXREM

What is REM, and why convert PX to REM?

rem stands for "root em" — a CSS unit sized relative to the font size of the root <html> element, rather than a fixed number of screen pixels. When someone increases their browser's default text size for readability, every value expressed in rem scales with it automatically; values in px don't move at all. That single difference is why most modern design systems — Tailwind, Material Design, Bootstrap 5 — default to rem for typography and spacing.

16px

The default root font size in every major browser, unless the user changes it.

÷ base

The entire conversion: rem = px ÷ root font size. No other variables involved.

1 root

Unlike em, rem always resolves against one single value, never a chain of parents.

PX vs REM vs EM — which unit to use where

These three units get confused constantly because they all describe "size," but they resolve completely differently.

UnitResolves againstScales with browser zoom / font settingsBest for
pxFixed screen pixelsNoBorders, hairlines, icon strokes, pixel-perfect details
remRoot (html) font size onlyYesTypography, spacing, layout — anything that should respect user preferences
emThe nearest parent element's font sizeYes, but compounds through nestingComponent-local sizing where an element should scale with its own text

How to use this PX to REM converter

  1. Set your root font size. Leave it at the browser default of 16px, switch to the 10px "62.5% trick," or type your design system's actual base value.

  2. Type a value in either field. Enter pixels to see the rem equivalent, or enter rem to see pixels — both fields stay in sync live, no "convert" button needed.

  3. Copy the ready-made CSS. The snippet box below the converter updates with a working declaration, plus a pixel-value comment for quick sanity-checking.

  4. Converting a whole stylesheet? Switch to Batch Convert, paste every pixel value from your CSS on its own line, and copy the full rem list back out.

  5. Need a cheat sheet? Open Reference Table for a scrollable px ↔ rem lookup at your chosen root size — handy to keep open in a second tab while you code.

Best practices for using rem in production CSS

DO

Use rem for font-size, margin, padding, and gap so your layout respects a user's accessibility settings.

DO

Keep px for 1px borders, box-shadow offsets, and icon strokes — things that should stay crisp regardless of text-size preferences.

DO

Declare your root font size explicitly in CSS (html { font-size: 100%; } or a specific px value) rather than leaving it implicit.

AVOID

Setting html { font-size: 62.5%; } purely to make mental math easier — it silently overrides a user's own browser font-size preference, which undercuts the accessibility benefit rem is supposed to provide.

AVOID

Mixing px and rem for the same property across similar components without a reason — it makes the scaling behavior of your UI unpredictable.

Frequently asked questions

How do I convert px to rem manually?

Divide the pixel value by your root font size. At the browser default of 16px, 24px ÷ 16 = 1.5rem. If your project sets the root to 10px, the same 24px becomes 2.4rem instead — the root size is the only variable that changes the answer.

Why isn't my rem value matching what I expected?

The most common cause is a root font size that isn't actually 16px — check for a html { font-size: ... } rule in your CSS (frameworks and resets often set it to 62.5% or another value), and use that number in the converter's "root font size" field instead of assuming the default.

Should every pixel value in my CSS become rem?

No. Typography, spacing, and layout dimensions benefit from scaling with user font-size preferences, so rem makes sense there. Hairline borders, box-shadow offsets, and other detail work that should stay fixed regardless of text size are usually fine left in px.

Does changing root font size break my layout?

Only if spacing and sizing were built entirely in px alongside rem-based type — the two can drift apart. Building both type and spacing in rem from the same root keeps proportions consistent no matter what the root size ends up being.

Is this px to rem converter free to use?

Yes — it runs entirely in your browser with no signup, no rate limit, and no data sent anywhere. You can convert a single value, batch-convert a whole list, or browse the reference table as often as you like.

Scroll to Top