rem To Pixels Converter
Convert CSS rem values to pixels and pixels back to rem using an editable root font size, with common spacing and typography examples.
Convert CSS Units
A rem is based on the font size of the root element, usually the html element. If the root font size is 16px, 1rem equals 16px. Change the root size when your project sets a different base.
Enter rem or px depending on mode.
The result card shows both units.
16px is the common browser default.
Keep enough precision for CSS tokens.
Changes the guidance note only.
Converted CSS Value
1.50rem x 16px root font size = 24.00px.
1.50rem
24.00px
16px
font-size: 1.50rem;
How rem And px Relate
The rem unit is relative to the root font size. In a page where the html element is 16px, 0.875rem is 14px, 1rem is 16px and 2rem is 32px. If the project changes the root to 10px, those same rem values become 8.75px, 10px and 20px. The converter keeps the root value visible so the calculation is repeatable.
Pixels are absolute CSS units for the purpose of the calculation. Browser zoom and device density can change how large a CSS pixel appears on a screen, but the CSS math still uses the root font size. That means the conversion is useful for code review, design tokens, spacing scales and moving a fixed px value into rem-based CSS.
For typography, rem is often preferred for user-friendly scaling. For tiny borders or hairline details, px may still be used. For layout, rem can make gaps and padding follow text scale, but very large layout widths may be better handled with %, ch, min(), max(), clamp() or container-based rules depending on the component.
Formula Used
pixels = rem x root font size in pxrem = pixels / root font size in pxWith a 16px root: 1rem = 16pxWith a 16px root: 24px / 16px = 1.5remThe root font size is the key assumption. Many sites leave it at the common browser default of 16px. Some older codebases set html to 62.5%, which often makes 1rem behave like 10px when the default is 16px. That shortcut can make mental maths easy, but it may also create accessibility issues if used carelessly.
Common rem To px Table
| rem | px at 16px root | px at 18px root | Typical Use |
|---|---|---|---|
| 0.75rem | 12px | 13.5px | Small helper text, used with care. |
| 0.875rem | 14px | 15.75px | Caption or compact interface text. |
| 1rem | 16px | 18px | Base body text. |
| 1.25rem | 20px | 22.5px | Small heading or spacious button text. |
| 1.5rem | 24px | 27px | Section heading or large spacing token. |
| 2rem | 32px | 36px | Large heading, modal padding or display spacing. |
Practical CSS Notes
If a designer hands over px values, converting them to rem can make the CSS scale more cleanly. For example, 24px becomes 1.5rem at a 16px root. If the project root later changes to 18px, that 1.5rem element becomes 27px, which may be intended for accessibility or may require design review.
Worked Examples
A button with 12px vertical padding and 20px horizontal padding converts to 0.75rem and 1.25rem at a 16px root. A heading specified as 32px converts to 2rem. A 14px caption converts to 0.875rem. If the root is 18px instead, those conversions become 0.667rem, 1.111rem, 1.778rem and 0.778rem, so always match the root font size used by the project.
When converting an entire spacing scale, avoid rounding every token too aggressively. A scale of 4px, 8px, 12px, 16px and 24px at a 16px root becomes 0.25rem, 0.5rem, 0.75rem, 1rem and 1.5rem. Those values are clean and easy to audit. A root of 15px creates less tidy decimals, where three decimal places may be useful.
Root Font Size Checks
Before converting a whole stylesheet, check where the root font size is set. It may be left to the browser default, set on the html element, inherited from a CSS reset or changed inside a theme file. If several files set the root size, agree one source of truth before moving many px values into rem. Otherwise the same token can produce different visual sizes across pages.
Also check whether the project uses media queries, prefers-reduced-motion, high-contrast modes or user-controlled text settings that affect typography. The conversion formula is simple, but a product interface may rely on line height, button height, icon alignment and form control spacing. After conversion, test long labels, error messages and compact cards, not only the one component that looked tidy in a design file.
Moving A px Scale To rem
A sensible migration starts with the scale rather than random individual values. Convert the base text size, then the spacing steps, then component-specific exceptions. Keep tokens readable: 0.25rem, 0.5rem, 0.75rem and 1rem are easier to maintain than a long list of values such as 0.3125rem and 0.9375rem unless the precision is truly needed.
Do not convert every px value blindly. Hairline borders, box shadows, image crop dimensions and canvas-style measurements may stay in px. Text, padding, margin, gap and radius often convert well. The best result is a system where values scale for readers without making the CSS harder to review.
FAQ
How many pixels is 1rem?
1rem equals the root font size. In many browsers and projects that is 16px, but the page or user settings can change it.
How do I convert px to rem?
Divide pixels by the root font size. At a 16px root, 24px divided by 16px is 1.5rem.
Is rem better than px?
It depends on the property. rem is often better for font sizes and spacing that should scale with text. px can still suit fine borders and exact visual details.
Does browser zoom change the formula?
No. The CSS conversion formula still uses the root font size. Zoom changes the displayed size, not the written CSS math.
What is the difference between rem and em?
rem is based on the root font size. em is based on the current element’s font size, so nested elements can compound.
Should I set html to 62.5%?
Some teams use it to make 1rem close to 10px, but it can cause accessibility and maintenance issues if handled poorly. Use the root size that fits the project and test text scaling.
Sources
- MDN Web Docs. (n.d.). CSS Values And Units. Mozilla. https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
- MDN Web Docs. (n.d.). font-size. Mozilla. https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
- World Wide Web Consortium. (n.d.). CSS Values And Units Module. W3C. https://www.w3.org/TR/css-values-4/
- Web Accessibility Initiative. (n.d.). Resize Text. W3C. https://www.w3.org/WAI/WCAG21/quickref/#resize-text
