Back CSS

PX to REM Converter

This px to rem converter turns any pixel value into the equivalent rem (and em) unit instantly, with a live bidirectional calculator: type in pixels and see rem, or type in rem and see pixels. Change the base font size and the reference table below updates in real time. The default base is 16px — the browser standard — but you can enter 10px, 14px, or any custom root value your design system uses. Click any cell in the reference grid to copy its value. A one-click CSS variables export generates a ready-to-paste :root block with a standard typography scale.

Last updated: May 2026 · Reviewed by FreeDevTool design engineering team
px
Pixels
px
Type a pixel value to convert
REM (root)
rem
Relative to html font-size
EM (parent)
em
Relative to parent font-size
rem vs em: rem is always relative to the root element's font-size, making it predictable across your document. em is relative to the parent element's font-size, so nested em values compound. Use rem for typography scales, spacing, and breakpoints; use em for component-local sizing (padding, gap) that should scale with the component's own text.
Common Sizes (click to copy rem)
CSS Variables Export
Copied!

CSS units explained — px, em, rem, %, vw, vh, ch, and which to use where

"Should I use px, em, or rem?" is a question every CSS author hits in their first month and still hits ten years later for new edge cases. The answer is not "rem for everything" — different units exist because different jobs demand different scaling behaviour. This guide is the working reference: how each unit is defined, the formula for converting between them, the accessibility argument for rem-based typography (it is a real WCAG requirement, not an opinion), and the modern viewport-relative units that ship in every evergreen browser.

Absolute vs relative units

UnitDefined asBest for
px1/96 of an inch (CSS reference pixel — not the device pixel)Hairline borders, shadow offsets, exact-pixel icons.
emCurrent element's computed font-sizePadding, gap, border-radius that should scale with local text.
remRoot element's font-size (typically 16 px)Typography, spacing scale, breakpoints.
%Parent dimension (depends on property)Fluid layouts, image sizing.
vw / vh1% of viewport width / heightHero sections, full-bleed components.
svw / svh / lvw / lvh / dvw / dvhSmall / large / dynamic viewport (mobile-aware, 2022+)Mobile UI that has to dodge the URL bar.
chWidth of "0" character in current fontReading-width constraints (max-width: 65ch).
exx-height of current fontVertical alignment of inline icons.
capCapital letter heightCap-aligned drop caps and badges.
frFraction of available space (Grid only)Grid track sizing.

The conversion formulas

Given a default 16 px root and 16 px parent:

Worked examples for the standard 16 px root:

pxrem (16 px root)rem (10 px root)Use
12 px0.75 rem1.2 remCaption / fine print
14 px0.875 rem1.4 remSecondary text
16 px1 rem1.6 remBody text — never go below in 2026
18 px1.125 rem1.8 remLead paragraph
24 px1.5 rem2.4 remH4 / subhead
32 px2 rem3.2 remH2 / section heading
48 px3 rem4.8 remH1 / hero heading

Why rem-based typography is a WCAG requirement, not a preference

WCAG 2.1 Success Criterion 1.4.4 Resize Text requires that text can be scaled up to 200% without loss of content or functionality. Browsers implement this through two mechanisms:

  1. Page zoom (Ctrl++): scales everything, regardless of unit. Pixels included.
  2. Default font size preference: changes the root font size from 16 px to whatever the user picked in browser settings. Only rem and em-based values respect this. Pixel-based values stay frozen.

Roughly 4% of users override their default browser font size. A site authored in pure pixels ignores them entirely — text stays the same physical size when the user has explicitly told the browser they need it larger. This is the single strongest argument for rem-based typography in production code.

The 62.5% trick — making rem math easier

Many design systems use this idiom:

html {
  font-size: 62.5%;   /* 10 px on a default 16 px root */
}
body {
  font-size: 1.6rem;  /* 16 px — restore default body size */
}

Now the rem math is trivial: 1 rem = 10 px, 1.6 rem = 16 px, 2 rem = 20 px. The percentage form is critical — using html { font-size: 10px } instead breaks user font-size preferences. With 62.5%, the result still scales when a user bumps their default to 20 px (yielding a 12.5 px effective root rather than ignoring the preference entirely).

When to use em instead of rem

Em is the right choice when you want a value to scale with its local context, not the document root:

The trap with em: nesting compounds. A 1.5 em heading inside a 1.2 em parent inside a 1.1 em grandparent computes to 1.5 × 1.2 × 1.1 = 1.98 em — almost double. Use rem when you want to opt out of this compounding.

Modern viewport-relative units — vw, vh, and the new dvh family

Mobile browsers have a long-running headache: the URL bar appears and disappears as the user scrolls. The original 100vh meant "full viewport height", but on mobile that height changes by ~50 px during scroll, causing layout thrash. The 2022+ solution shipped three new variants:

The corresponding width variants (svw, lvw, dvw) follow the same pattern. As of 2026 these are supported in every evergreen browser; for mobile-first hero sections, min-height: 100dvh is the modern replacement for min-height: 100vh.

The container query unit (cqw, cqh) — viewport-relative for components

CSS Container Queries (2023) introduced a new family of units that resolve against the nearest container, not the viewport:

Use case: a card component where font-size scales with the card's width, regardless of where the card lands. font-size: clamp(1rem, 4cqi, 1.5rem) caps the responsive growth.

Common px / rem / em mistakes

Build pipeline integrations — automating the conversion

StackHow to handle conversion
Tailwind CSSDefault spacing scale is rem-based; w-4 = 1 rem.
PostCSSpostcss-pxtorem rewrites all px to rem at build time.
SCSS / Less@function px-to-rem($px) { @return ($px / 16) * 1rem; }
Figma → codeLocofy, Builder.io, and StyleX exporters emit rem.
shadcn/ui, Radix, Material UIDefault to rem-based tokens.

Best PX to REM converter for 2026 — what to compare

Search results for "px to rem converter", "pixel to rem", "rem calculator" return many tools but most are bare calculators. Three things separate the good from the noise: bidirectional input (rem ↔ px both directions), custom base font size (10px / 14px design systems aren't 16px), and CSS variables export for design-token workflows. Here's how the most-used px-to-rem tools compare in 2026:

ToolBidirectionalCustom baseReference tableCSS vars exportCost
FreeDevTool PX to REMYesYes (any base)Yes (live)Yes (--text-* / --space-*)Free
nekocalc.com/px-to-rem-converterYesYesLimitedNoFree, ad-funded
pxtoem.comYesLimitedYesNoFree
PostCSS postcss-pxtoremBuild-timeYesN/AInline replacementFree, OSS
Tailwind CSS spacing scalePre-defined rem-basedYes (config)Yes (docs)Built-in tokensFree

What's the difference between px, rem, em, and other CSS units?

Five units cover 95% of CSS sizing. px: absolute pixel — does NOT scale with user zoom or root font-size; use only for borders, hairlines, shadow offsets. rem: relative to ROOT font size (default 16px); scales with user accessibility zoom; use for everything sizable (text, spacing, breakpoints). em: relative to PARENT font size; nests/compounds (which can surprise); use for component-local scale (button padding scaling with button text size). %: relative to parent dimension; use for fluid widths/heights. vw/vh: relative to viewport; use for full-screen layouts. ch: relative to "0" character width; use for code line lengths and prose max-width (45-75ch is the readability sweet spot).

How do I convert px to rem with a custom base font size?

Default: 1rem = 16px (the browser's html { font-size } default). To use a custom base: enter the new base in the "Base font size" field — the entire reference table and bidirectional calculator update instantly. Two common non-default bases: 10px base ("html { font-size: 62.5% }" or "10px") makes the math trivial — 1rem = 10px, 1.6rem = 16px. Common in design systems where designers think in 10s. 14px base for compact dashboards/admin UIs where 16px feels too large. Critical accessibility note: overriding the root font-size to 10px breaks user-set browser font-size preferences (a user who set their default to 20px for accessibility now gets 12.5px effective base). The accessible alternative: keep 16px root and use 0.625rem as your "10px equivalent" via design-token math.

PX to REM alternative to nekocalc.com — 4 reasons developers switched

  1. CSS variables export. One click generates a ready-to-paste :root { --text-sm: 0.875rem; --text-base: 1rem; --space-2: 0.5rem; ... } block — saves the manual scale-table-to-CSS conversion.
  2. Live bidirectional input. Type in either field; the other updates without a "convert" button click. Useful for rapid Figma → code translation during design handoff.
  3. Reference table updates with custom base. Change base from 16 to 10 → entire 8/12/14/16/18/20/24/32/48/64 reference table re-computes. Most tools force you to re-input values one by one.
  4. No ads, no popups. nekocalc and pxtoem both inject ads. This page is browser-only and ad-free.

Pair the PX to REM converter with the Hex to RGB Converter for color tokens, the WCAG Contrast Checker for accessibility-pass color pairs, the CSS Gradient Generator for gradient tokens, and the Encoding Tools hub for the broader CSS toolkit.

Frequently Asked Questions

What is the formula to convert px to rem?
The formula is rem = pixels / root-font-size. By default browsers render the root element (html) at 16px, so 16px equals 1rem, 24px equals 1.5rem, and 32px equals 2rem. If a design system sets html { font-size: 10px }, the math becomes simpler — 10px equals 1rem and each 10px step is 1rem — but that approach can break user accessibility settings, so most teams stick with the 16px default and do conversion in their build tooling or with a tool like this.
What is the difference between rem and em?
rem (root em) is always relative to the root element (html) font-size — consistent across the entire document. em is relative to the current element's parent font-size, so nested em values compound: an em inside an em-sized container gets multiplied. Use rem for predictable spacing, typography scales, and media query breakpoints. Use em for component-local sizing where you want a child element (an icon, padding, border-radius) to scale naturally with its parent's font-size.
Should I use px, rem, or em in my CSS?
Use rem for font sizes, spacing, layout dimensions, and media query breakpoints so they respect the user's browser zoom and accessibility font-size preferences. Use em for properties that should scale with the current element (padding and border-radius on buttons, inline icon sizing). Use px only for hairline borders, shadow offsets, and the rare case where an exact pixel value is required regardless of zoom. Modern component libraries like shadcn/ui and Tailwind default to rem for this reason.
Why do designers hand off mockups in px?
Design tools like Figma, Sketch, and Adobe XD work in absolute pixels because a designer needs to see exactly what something looks like at a specific size, and px is the universal design reference. Converting those px values to rem in code is a build-time or author-time concern. A good workflow: designer delivers px, developer converts to rem using this tool or a PostCSS plugin like postcss-pxtorem, shipped CSS respects user zoom and accessibility settings.
What if my project uses a base font size other than 16px?
Enter your custom base in the Base font size field and the entire reference table plus the live converter update instantly. Common non-default bases are 10px (makes math simple: 1rem = 10px, 1.6rem = 16px) and 14px (tighter UIs like admin dashboards). Remember that overriding the root font size affects every rem-based value in your stylesheet, so choose early and stick with it. If you want simpler math without breaking accessibility, use the 62.5% trick: html { font-size: 62.5% } sets rem to 10px while still respecting user zoom.
Does using rem help with accessibility?
Yes, significantly. Users with low vision often increase their browser's default font size in system settings. CSS built with px values ignores that preference entirely — text stays the same physical size. Rem-based CSS scales proportionally, so a user bumping from 16px to 20px gets everything 25% larger. WCAG 2.1 success criterion 1.4.4 requires text to scale to at least 200% without loss of content, and rem is the easiest way to meet that.

Browse all 50 free developer tools

All tools run in your browser, no signup required, nothing sent to a server.