Skip to content

PX to percent converter

Convert a pixel font size to a percentage of its parent, the notation used for accessible base sizing and for fluid layout widths.

  • Runs in your browser
  • Nothing you enter is sent
  • Free, no account
Pixels (px) to Percent (%)
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.

For font-size, a percentage of the parent font size: 100% = the parent size.

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
100%
At a 16 px root and a 16 px parent.
px
16
rem
1
em
1
pt
12
%
100
percent = px ÷ parent font size (16 px) × 100
100% = 16 px ÷ 16 px × 100
(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.

Percentages are relative to different things

This is the single most important thing to know about percentages in CSS, and it is why they cause more layout surprises than any other unit. The reference depends on the property.

PropertyPercentage is of…
font-sizeThe parent’s font size — this is what the converter above computes
width, max-width, left, rightThe containing block’s width
height, top, bottomThe containing block’s height — and it is ignored if that height is auto
padding and margin, all four sidesThe containing block’s width, including top and bottom
line-heightThe element’s own font size
transform: translate()The element’s own size
background-positionThe positioning area minus the image size
border-widthNot allowed — percentages are invalid here

The padding row is the famous one, and it is genuinely useful: padding-top: 56.25% on an empty box produces a 16:9 aspect ratio, because 9/16 = 0.5625 of the width. Modern CSS has aspect-ratio for this, but the trick is still everywhere in older code.

Percentage font sizing

% = px ÷ parent font size × 100

Parent 16px:
  14px → 87.5%
  18px → 112.5%
  20px → 125%

A percentage font size is arithmetically identical to em — 87.5% and 0.875em compute to exactly the same value — so it compounds through nesting in exactly the same way. Four nested levels of 90% leave you at 65.6% of where you started.

Where percentage font sizing is still standard

On the root element, where it means something rem and em cannot:

html { font-size: 100%; }   /* respect the user's chosen size */
html { font-size: 62.5%; }  /* the "1rem = 10px" trick */

100% is the honest default. It is also the reason not to write html { font-size: 16px }: that pins the root to 16 regardless of what the user asked for, which defeats the whole point of using rem below it.

Converting a width to a percentage

Set the parent field to the container’s width in pixels rather than a font size, and read the percentage. A 320px sidebar inside a 1200px container is 26.6667%.

Two caveats before you use that number. Percentage widths do not account for gaps, padding or borders unless box-sizing: border-box is set, so three columns at 33.3333% with a gap will wrap. And in most modern layouts you should not be computing this at all — CSS Grid (grid-template-columns: 2fr 1fr) and Flexbox handle the arithmetic and the gaps for you.

Repeating decimals

A third is 33.333…%, and where you truncate matters. Browsers work in sub-pixel precision, so 33.3333% is close enough that rounding is invisible; 33.33% across three columns of a 1200px container leaves a 0.36px gap, which sounds like nothing and shows up as a one-pixel seam against a contrasting background. Use four decimal places, or use fr units and let the layout engine distribute the remainder exactly.

Questions

What is a percentage relative to?

It depends on the property, which is why percentages catch people out. For `font-size` it is the parent's font size — that is what this converter computes. For `width` it is the containing block's width; for `padding` and `margin`, even the vertical ones, it is the containing block's *width*; for `line-height` it is the element's own font size.

Where is percentage font sizing still used?

Mostly on the root element. `html { font-size: 100% }` is the standard way to say "respect whatever the user chose", and `62.5%` is the well-known trick that makes 1 rem equal 10 px. Below the root, rem and em are easier to reason about.

Do percentages compound like em?

Yes, identically — a percentage font size is em expressed differently. Nested elements each multiplying by 90% shrink just as fast. Use rem if you want to escape that.

How do I convert a pixel width to a percentage?

Set the parent size field to the container's width in pixels rather than a font size, then read the percentage. A 320 px column inside a 1200 px container is 26.6667% — and in a modern layout you would probably reach for grid or flex instead.