CSS px to rem Converter
Convert between px, rem, em, pt, percent, and vw CSS units instantly
Unit Converter
Formulas
rem = px / base-font-sizeem = px / parent-font-size (same as rem at root)pt = px * 0.75% = (px / base-font-size) * 100vw = (px / viewport-width) * 100Visual Preview
Conversion History
- No conversions yet
Bulk CSS Converter
Paste CSS code with px values to auto-convert them to rem or em.
Quick Reference Table
px to rem values based on current base font size (16px).
| px | rem | em | pt | % |
|---|
Drop a pixel value in, get rem, em, pt, percent, and vw back instantly — or paste an entire CSS block and bulk-convert every px declaration in one click. No more dividing by 16 in your head over and over while porting a Figma mockup to code.
Set any base font size (not just 16px) and the math adjusts across all units automatically. And everything runs in your browser. Nothing gets uploaded.
How It Works
The math is simple: divide your pixel value by the root font size. With a 16px base, 24px becomes 1.5rem. But it gets tedious when you have dozens of values and your base isn’t always 16. The converter does this division for every unit simultaneously, and the bulk mode runs a regex across your whole stylesheet so you don’t miss anything.
Examples
Converting body text size
Your designer specifies 18px body text but you want rem for accessibility.
18px (base: 16px)
1.125rem
1.125em
13.5pt
112.5%
Bulk-converting a button component
You’ve got a CSS block full of pixel values that all need to become rem at once.
.btn {
padding: 12px 24px;
font-size: 14px;
border-radius: 8px;
margin-bottom: 16px;
}
.btn {
padding: 0.75rem 1.5rem;
font-size: 0.875rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
}
Non-standard base font size
Some projects set html { font-size: 10px } for easier math. The conversion changes completely.
20px (base: 10px)
2rem (not 1.25rem!)
15pt
200%
Who Uses This
Converting pixel-based mockups to rem-based CSS for responsive and accessible layouts.
Checking what their Figma pixel specs translate to in real CSS units before handoff.
Building fluid layouts that scale across phone, tablet, and desktop viewports.
Learning the difference between absolute and relative CSS units for coursework.
Common Mistakes
If your project uses html { font-size: 62.5% } (which sets the base to 10px), converting with a 16px base gives you wrong rem values. Always match the base here to whatever your stylesheet actually uses.
A 1px border should usually stay as 1px. Converting it to 0.0625rem means it might render as 0px or 2px depending on the screen. Keep borders, box-shadows, and outlines in pixels.
Rem is always relative to the root element. Em is relative to the parent’s font size. If you nest elements with em-based sizing, values compound — a 2em inside another 2em gives you 4x the root size. Stick with rem unless you specifically want that cascading effect.
Technical Details
- Processing: 100% client-side — no data sent to any server
- Supported Units: px, rem, em, pt, %, vw
- Browser Support: Chrome, Firefox, Safari, Edge
- Bulk Mode: Regex-based find-and-replace across full CSS blocks
- Decimal Precision: Configurable from 1–6 decimal places
Frequently Asked Questions
What is 1rem in pixels?
It depends on your root font size. Most browsers default to 16px, so 1rem = 16px. If you’ve set html { font-size: 20px }, then 1rem = 20px. There’s no universal answer — it’s always tied to that root value.
Should I convert all px values to rem?
Not everything. Font sizes, padding, margins, and widths benefit from rem because they’ll scale with user preferences. But borders, box-shadows, and tiny decorative details are better left in px. A 1px border that scales to 0.8px looks broken.
What is the difference between rem and em?
Rem always references the root html font size. Em references the font size of the current element’s parent. That means em values compound when you nest elements — 1.5em inside 1.5em gives you 2.25x the root. Rem doesn’t have that compounding problem, which is why most teams prefer it.
Why do some projects use font-size: 62.5%?
Setting 62.5% on the html element makes the base 10px (62.5% of 16px). Then the math is dead simple: 14px = 1.4rem, 20px = 2rem. It’s a popular trick, but some accessibility advocates argue it can cause issues if users override their default font size. Either way, make sure your converter base matches.
Is this tool safe to use with production CSS?
Your code never leaves your browser — zero server requests. The bulk converter also won’t touch non-px values, so your colors, percentages, and other properties stay exactly as they are. Still, it is good practice to review the output before pasting it into your production stylesheet.