Skip to content

PX to EM converter

Convert px to em against the parent font size, with a bulk stylesheet rewrite and a note on the compounding trap that makes em surprising.

  • Runs in your browser
  • Nothing you enter is sent
  • Free, no account
Pixels (px) to Em (em)
Convert a single value, or paste a whole stylesheet and rewrite every length at once. The root and parent font sizes below drive every number on this page.

A CSS pixel — an absolute unit in CSS terms, independent of the device pixel ratio.

Relative to the font size of the element itself (or its parent, for the font-size property).

The rem basis. 16 px unless you changed the html font-size.

The em and % basis — the computed font size of the element's parent.

16px equals
1em
At a 16 px root and a 16 px parent.
px
16
rem
1
em
1
pt
12
%
100
em = px ÷ parent font size (16 px)
1em = 16 px ÷ 16
(via 16 px)
The conversion with your own numbers substituted in.
Bulk rewrite a stylesheet
Paste CSS and every matching length is converted at once. Strings, comments and url() bodies are copied through untouched, and each category of value can be left alone.
Reference table
Every common size at a 16 px root font size. Change the root above and the whole table re-computes.
Pixel values converted to rem, em, points and percent
pxremempt%
1px0.0625rem0.0625em0.75pt6.25%
2px0.125rem0.125em1.5pt12.5%
4px0.25rem0.25em3pt25%
6px0.375rem0.375em4.5pt37.5%
8px0.5rem0.5em6pt50%
10px0.625rem0.625em7.5pt62.5%
11px0.6875rem0.6875em8.25pt68.75%
12px0.75rem0.75em9pt75%
13px0.8125rem0.8125em9.75pt81.25%
14px0.875rem0.875em10.5pt87.5%
15px0.9375rem0.9375em11.25pt93.75%
16px1rem1em12pt100%
17px1.0625rem1.0625em12.75pt106.25%
18px1.125rem1.125em13.5pt112.5%
20px1.25rem1.25em15pt125%
22px1.375rem1.375em16.5pt137.5%
24px1.5rem1.5em18pt150%
26px1.625rem1.625em19.5pt162.5%
28px1.75rem1.75em21pt175%
30px1.875rem1.875em22.5pt187.5%
32px2rem2em24pt200%
36px2.25rem2.25em27pt225%
40px2.5rem2.5em30pt250%
44px2.75rem2.75em33pt275%
48px3rem3em36pt300%
56px3.5rem3.5em42pt350%
64px4rem4em48pt400%
72px4.5rem4.5em54pt450%
80px5rem5em60pt500%
96px6rem6em72pt600%
Your CSS never leaves this tab — check it yourself—

Starting the network probe…

The counter above wraps fetch, XMLHttpRequest and navigator.sendBeacon in this tab and counts every call. It does not block anything — it just reports.

Two ways to verify independently

  1. Turn off Wi-Fi or enable airplane mode, then use the tool. It keeps working, because the page is already fully loaded.
  2. Open your browser devtools, switch to the Network tab, clear it, and run the tool. No new row appears.

Why this matters

In 2025 researchers found that popular online formatters had retained tens of thousands of user-submitted snippets — JSONFormatter.org and CodeBeautify together exposed roughly 80,000 saved documents, many containing live cloud credentials, private keys and internal database connection strings, because “format this” quietly meant “upload this”. A separate incident exposed roughly 3.5 million user PDFs on a document-conversion service. The only structural fix is not sending the data in the first place: this site is served under a Content-Security-Policy whose connect-src contains no third-party origin, so a request off this device cannot be made even by accident.

What em is relative to

For every property except one, em resolves against the computed font-size of the element itself. For font-size, it resolves against the parent’s font size. That single exception is the source of nearly all em confusion, and it is worth reading twice.

.card {
  font-size: 1.25em;   /* 1.25 × the PARENT's size */
  padding: 1em;        /* 1 × THIS element's size, i.e. 1.25 × parent */
}

Set the parent font size field above to whatever the containing element computes to — read it from the Computed panel in devtools — and the conversion matches what the browser will do.

The compounding trap

em multiplies down the tree, and inherited rules multiply with it.

ul { font-size: 0.9em; }

Level 1: 16px × 0.9 = 14.4px
Level 2: 14.4 × 0.9 = 12.96px
Level 3: 12.96 × 0.9 = 11.66px
Level 4: 11.66 × 0.9 = 10.5px   ← unreadable

Nothing here is a bug; it is em working exactly as specified. The fix is either to scope the rule so it cannot nest (:not(ul ul), or a class rather than an element selector) or to use rem, which is immune because it always resolves against the root.

Where em is the right choice

Component-internal measurements that should track the component’s own text size. Define a button once in em and it works at every size, because everything inside it scales together:

.button {
  font-size: 1rem;        /* the one dial */
  padding: 0.625em 1em;   /* 10px / 16px at this size */
  border-radius: 0.375em;
  gap: 0.5em;
}

.button--sm { font-size: 0.875rem; }  /* everything shrinks proportionally */
.button--lg { font-size: 1.125rem; }  /* everything grows proportionally */

Two size modifiers, one declaration each. In rem you would have to restate the padding, radius and gap for every size.

Other good uses

  • Icon sizing. width: 1em; height: 1em makes an inline SVG match the surrounding text exactly, at any size.
  • Media queries. Inside a media query em resolves against the browser’s initial font size, never your declared root, which makes em breakpoints more predictable than rem ones in a project that changes the root size.
  • Text indentation and hanging punctuation, which should be proportional to the type by definition.

The bulk rewrite cannot know your tree

When you paste a stylesheet, the converter applies the single parent font size you set at the top to every value it rewrites. It has no way to know that .card p sits inside something that set 1.25em — that depends on the DOM, not the stylesheet. For a file with several nested type contexts, convert one section at a time with the right parent size for each, or use the property filter to limit the rewrite to a single property.

Questions

What is em relative to?

The font size of the element itself — except for the `font-size` property, where it is relative to the parent. That single exception is the source of most em confusion. Set the parent font size field on this page to whatever the containing element computes to.

What is the compounding problem?

em multiplies down the tree. If a list sets `font-size: 0.9em` and a nested list inherits the same rule, the second level is 0.81em, the third 0.729em, and by the fourth your text is unreadable. rem avoids this entirely because it is always relative to the root.

So when should I use em?

When you want something to scale with its own text. Padding inside a button, the gap between an icon and its label, and a border-radius on a chip all look right in em because they track the component's font size wherever it is used. Global type scales belong in rem.

Does the bulk rewrite know the parent size of each rule?

No, and it cannot — that depends on where the element lands in the DOM. The rewrite applies the single parent size you set at the top. For a stylesheet with several nested contexts, convert one section at a time.