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: March 2026
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!

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.