Tools

Home
CSS BeautifierTailwind to CSSBox ShadowBorder RadiusGlassmorphism

CSS px to rem Converter

Convert between px, rem, em, pt, percent, and vw CSS units instantly

Your files never leave your browser

Unit Converter

px (root html font-size)
Pixels (px)16
REM1
EM1
Points (pt)12
Percent (%)100
Viewport Width (vw)--

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) * 100

Visual Preview

The quick brown fox jumps over the lazy dog.

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).

pxremempt%

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

Enter PX Value
→
Divide by Base (16px)
→
Get REM + Other Units

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.

INPUT
18px (base: 16px)
OUTPUT
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.

INPUT
.btn { padding: 12px 24px; font-size: 14px; border-radius: 8px; margin-bottom: 16px; }
OUTPUT
.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.

INPUT
20px (base: 10px)
OUTPUT
2rem (not 1.25rem!) 15pt 200%

Who Uses This

👨‍💻 Frontend Developers

Converting pixel-based mockups to rem-based CSS for responsive and accessible layouts.

🎨 UI Designers

Checking what their Figma pixel specs translate to in real CSS units before handoff.

📱 Mobile Web Developers

Building fluid layouts that scale across phone, tablet, and desktop viewports.

🎓 CS Students

Learning the difference between absolute and relative CSS units for coursework.

Common Mistakes

Forgetting to change the base font size

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.

Converting border widths to rem

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.

Mixing em and rem without understanding scope

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

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.

Share: