PX to REM Converter (and REM to PX)
Convert pixels to rem and rem to pixels with any root font size, paste whole CSS blocks to convert every px value at once, keep 1px borders intact, and copy a reference table for your design system.
PX ⇄ REM Workspace
Convert a single value or paste a whole stylesheet. Change the root font size if your project does not use 16px.
24px = 1.5rem /* root 16px */
Why Developers Use the Agenvix PX to REM Converter
Accessible, scalable CSS without mental arithmetic.
Convert Entire Stylesheets
Paste CSS, SCSS or inline styles and every px value is converted in place, including shorthand like 24px 32px and media queries.
Keeps Hairlines Crisp
A minimum-pixel threshold leaves 1px and 2px borders alone so they do not become 0.0625rem and blur on scaling.
Any Root Size
Works with 16px defaults, the 62.5% trick (10px) or any custom html font-size your framework uses.
Design-System Table
A copyable px ↔ rem table for common sizes to paste into documentation or tokens.
Simple as 1-2-3
How the Converter Works
The maths is simple; the tool just removes the friction.
Enter a Value or CSS
Type a number in the px or rem field, or switch to CSS mode and paste a stylesheet.
Divide by the Root Size
rem = px ÷ root font size, px = rem × root font size. Precision and the minimum px threshold are configurable.
Copy the Result
Copy the single value, the converted CSS or the reference table.
CSS Length Units Compared
When to use each relative unit.
| Feature / Specification | Best Use Case | Engine / Output Standard | Privacy & Security | Performance Rating | Action |
|---|---|---|---|---|---|
| rem | Font sizes, spacing, layout widths | Relative to html font-size | Scales with user prefs | Recommended | |
| em | Padding inside components, icons | Relative to parent font-size | Compounds when nested | Contextual | |
| px | Borders, shadows, hairlines | Absolute (CSS px) | Ignores browser font setting | Limited | |
| % | Fluid widths | Relative to containing block | Layout only | Layout | |
| vw / vh / clamp() | Fluid typography | Viewport-relative | Combine with rem | Advanced |
Pixels, rems and Accessible Sizing
1. The formula and the 16px default
Browsers default the root font size to 16px, so 1rem = 16px, 0.5rem = 8px and 1.5rem = 24px. The conversion is rem = px ÷ root size. If a user changes their browser font setting to 20px, every rem value scales with it; px values do not. That single fact is why rem is the accessible default for type and spacing.
2. The 62.5% trick
Setting html { font-size: 62.5%; } makes 1rem equal 10px for easier arithmetic while still respecting user preferences. Set the root size to 10 in this tool to match. Two caveats:
- You must reset body text to 1.6rem or it renders at 10px.
- Third-party components that assume 1rem = 16px will look small.
3. What should stay in pixels
Borders, outlines, hairline dividers and box-shadow offsets usually look better fixed at 1px or 2px; scaling them with text produces blurry fractional lines. Media query breakpoints are debated: em-based queries scale with zoom, while px breakpoints are simpler to reason about. The bulk converter skips values below the threshold you set so borders survive.
4. rem in Tailwind and design tokens
Tailwind's spacing scale is defined in rem (p-4 = 1rem = 16px, text-lg = 1.125rem = 18px), so designers handing off px values need this conversion constantly. Document tokens in both units, generate them from a single source and keep precision to three or four decimals; 0.6875rem is exact for 11px but 0.69rem rounds to 11.04px.
Everything you need to know about px and rem
Formula, root size, em vs rem and bulk conversion.
How do I convert px to rem?
Divide the pixel value by the root font size. With the default 16px root, 24px ÷ 16 = 1.5rem. The tool does this for single values and for every px in a pasted stylesheet.
What is the difference between rem and em?
rem is relative to the html element font size and is the same everywhere. em is relative to the current element font size, so nested em values compound. Use rem for layout and type scale, em for sizing relative to local text such as icons and button padding.
What root font size should I use?
Keep 16px unless your project explicitly sets html font-size. If it uses 62.5% (10px) or a custom value, enter that number so the conversions match.
Why does the bulk converter skip 1px values?
By default values under 3px are left as px because borders and hairlines should not scale. Set the threshold to 0 to convert everything.
Does the converter handle negative and decimal values?
Yes. -0.5px letter-spacing and 1.5px values convert correctly, and the threshold compares absolute values.
How many decimals should I keep?
Four decimals represent every integer px value exactly for a 16px root. Trailing zeros are trimmed automatically.
Can I convert rem back to px?
Yes. Edit the rem field in single mode, or paste CSS and choose rem → px in CSS mode.
Is my CSS uploaded?
No. Conversion runs in your browser.
Related Developer Utilities
Discover companion utilities engineered for zero-log speed and browser-side execution.
Aspect Ratio Calculator
Reduce any dimensions to a ratio, solve the missing width or height and copy CSS aspect-ratio code.
CSS Gradient Generator
Design linear and radial gradients with precise colour stops and copy production ready CSS.
CSS Box Shadow Generator
Layer multiple box shadows with live preview, elevation presets and copy-ready CSS or Tailwind output.
Color Converter
Convert HEX, RGB, HSL, HSV and CMYK colours with alpha, WCAG contrast checks and tint and shade scales.
Number Base Converter
Convert between binary, octal, decimal, hex and base36 with exact BigInt math.
HTML Entity Encoder
Escape reserved HTML characters or resolve named and numeric entities back to plain text.
More in Code & Data
Specialized utilities within the same technical domain
