⚡ BreezyTools Pro — Ad-free experience across all 200+ tools. Less than a coffee a month → Learn More

EM / REM / PX Converter

Convert between CSS em, rem, and px with a custom base font size.

Convert CSS px, em, and rem

This converter translates CSS lengths between pixels (px), em, and rem using a base font size you choose. Front-end developers use it to turn pixel values from a design mockup into scalable rem or em units, to check what an existing rem value renders as, and to build type scales and spacing systems.

How to Use the Converter

  1. Set the Base font size (px). The default is 16, the default root font size in major browsers.
  2. Type a value into the PX, EM, or REM box. The other two update instantly; px values show two decimal places and em/rem values show three.
  3. Click Copy next to any box to copy that number.

Changing the base size recalculates em and rem from the current px value. The tool uses the same base for both em and rem, so they always show the same number. That is exactly right for rem, and right for em when the element's parent font size equals the base. Inside a component whose parent text is 20px, set the base to 20 to get correct em values.

The Formulas

  • rem = px ÷ root font size, and px = rem × root font size
  • em = px ÷ reference font size, and px = em × reference font size

For the font-size property, an em refers to the parent element's font size. For other properties such as padding, margin, or width, an em refers to the element's own computed font size.

Worked Examples

  • 24px heading, base 16: 24 ÷ 16 = 1.5rem.
  • 0.875rem, base 16: 0.875 × 16 = 14px.
  • 27px padding in an 18px component: set the base to 18; 27 ÷ 18 = 1.5em.

px to rem Reference (16px base)

pxrempxrem
100.625201.25
120.75241.5
140.875322
161483
181.125644

Tips and Common Mistakes

  • Em values compound. If a list and its nested list both use font-size: 1.2em, the inner text is 16 × 1.2 × 1.2 = 23.04px. Rem does not compound because it always refers to the root.
  • If your stylesheet sets html { font-size: 62.5% }, 1rem equals 10px at the default browser setting, so enter 10 as the base.
  • Inside media queries, em and rem are based on the browser's initial font size (usually 16px), not the font size you set on the html element.

Frequently Asked Questions

How many pixels is 1rem?

1rem is 16px by default in modern browsers. It changes if your CSS sets a different font size on the html element or if the user changes the default font size in browser settings.

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16px root, 20px ÷ 16 = 1.25rem and 12px ÷ 16 = 0.75rem.

What is the difference between em and rem?

Rem is always relative to the root html element's font size. Em is relative to the parent's font size when used for font-size, and to the element's own font size for other properties, so em values can compound in nested elements.

Should I use rem or px for font sizes?

Rem is generally recommended for font sizes because it scales with the user's preferred browser text size, which helps accessibility. Pixels are still common for borders, shadows, and other fine details that should not scale.

Why don't my em values match the browser?

Usually because the parent font size is not 16px or because em values are compounding through nested elements. Check the parent's computed font size in your browser's developer tools and enter it as the base.

How many decimal places does the converter show?

Pixel values are shown to two decimal places and em/rem values to three, which is precise enough for CSS. Browsers accept more decimals if you need them.

Love using BreezyTools?

Go Pro for an ad-free experience, priority features, and support independent development — for less than a coffee a month.

Upgrade to Pro →