Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Pixel to EM Calculator

Convert px values to em units based on parent font size — single, batch, or full CSS conversion

Your files never leave your browser
pxFormula: em = px ÷ parent
16px = 1em
at parent font size of 16px
PX Values (one per line)
EM Results
CSS with px values
CSS with em values
Ready·Parent: 16px

Quick Reference Table

PixelsEMCSS

Drop in a pixel value — or paste an entire stylesheet — and get the em equivalent instantly. Set a custom parent font size if you're not working with the default 16px, and the math updates on the fly. And everything runs in your browser. Nothing gets uploaded.

How It Works

Enter px value
➔
Divide by parent font size
➔
Get em result

The formula is straightforward: em = px ÷ parent font size. If your parent element has a font size of 16px (the browser default), then 24px becomes 1.5em. Change the parent to 20px and that same 24px turns into 1.2em. The tool handles the division and rounding — you pick how many decimal places you want.

Examples

Body text sizing at default root

Most common scenario — converting a 14px body font with a 16px parent.

INPUT
14px (parent: 16px)
OUTPUT
0.875em

Button padding inside a card with 20px font

The parent font size here is 20px, not the default. A designer specifies 10px vertical and 24px horizontal padding on a button.

INPUT
10px, 24px (parent: 20px)
OUTPUT
0.5em, 1.2em padding: 0.5em 1.2em;

Full CSS block conversion for a navbar

You've got a whole ruleset with pixel values and need the em equivalent in one shot. Paste the CSS block into the CSS mode.

INPUT
.nav { font-size: 18px; padding: 12px 32px; gap: 8px; }
OUTPUT
.nav { font-size: 1.125em; padding: 0.75em 2em; gap: 0.5em; }

Who Uses This

👨‍💻 Front-End Developers

Converting pixel-based design specs into scalable em values for component stylesheets.

🎨 UI Designers

Checking how Figma pixel values translate to em before handing off to engineering.

📚 Students

Learning CSS relative units and verifying homework calculations against a known-good tool.

⚡ Email Developers

Building responsive email templates where em-based sizing behaves more predictably across clients.

Common Mistakes

Forgetting to change the parent font size

The default is 16px, but if your parent element uses a different size, every calculation will be wrong. Always check the computed font-size in DevTools before converting.

Confusing em with rem

em is relative to the parent element, rem is relative to the root. If you're nesting components, em compounds — 1.5em inside a 1.5em parent gives you 2.25× the root size, not 1.5×. Use rem if you don't want that cascading effect.

Over-rounding the result

Rounding 0.875em to 0.9em seems harmless, but on a 1920px-wide layout that difference adds up. Keep at least 3 decimal places for font sizes, or use the exact fraction when precision matters.

Technical Details

Frequently Asked Questions

How do I convert px to em?

Divide the pixel value by the parent element's font size. So 24px with a 16px parent = 24 ÷ 16 = 1.5em. That's it. If the parent is something other than 16px, the result changes — which is the whole reason em can be tricky.

What's the difference between em and rem in CSS?

rem always refers to the root HTML element's font size (usually 16px). em refers to whatever the parent element's font size happens to be. The big gotcha with em is compounding — nest a 1.5em inside another 1.5em and you get 2.25× the root, not 1.5×. rem doesn't do that.

Is 1em always equal to 16px?

Only if the parent font size is 16px, which is the browser default. If someone sets body font-size to 18px, then 1em = 18px inside that body. And if a nested div has font-size: 20px, then 1em inside that div = 20px. Context is everything with em.

When should I use em instead of px?

Use em for things that should scale with the text around them — button padding, icon sizing next to labels, spacing between list items. Px is fine for stuff that shouldn't change regardless of text size, like a 1px border or a fixed-width sidebar.

Does this tool send my CSS to a server?

No. Every calculation happens right in your browser with JavaScript. Nothing gets uploaded, stored, or logged anywhere. You could disconnect from the internet and the tool would still work fine.

Share: