PX to REM Converter

Convert CSS units: px to rem, em, pt, %, vw and vh and back, with your own root font size – and turn all px values of a stylesheet into rem at once.

Runs locally in your browser
24px
1.5rem
1.5em
18pt
150%
1.6667vw
2.6667vh
Base values
×
Common sizes
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
28px1.75rem
32px2rem
40px2.5rem
48px3rem
64px4rem
Convert a stylesheet
e.g. 2 keeps 1px borders in px

About this tool

The design says 24px, the CSS should use rem: this calculator converts a length into all common CSS units – px, rem, em, pt, %, vw and vh. You set the reference values yourself: the root font size for rem (default 16 px), the parent element’s font size for em and %, and the viewport size for vw and vh.

For whole stylesheets there is the second part: paste CSS and all px values turn into rem at once. Comments, strings and url(…) stay unchanged, and you can leave tiny values such as 1px borders out. Calculate fluid sizes with clamp() using the CSS clamp() Generator, aspect ratios with the Aspect Ratio Calculator.

How it works

  1. Enter a value and choose its unit, e.g. 24 and px.
  2. Read the result in all units and copy the value you need.
  3. Adjust the base values if needed, such as a root font size of 10 px.
  4. For a whole stylesheet, paste the CSS below and copy the converted version.

Frequently asked questions

How do I convert px to rem?

Divide the px value by the root font size. With the browser default of 16 px, 24px is 24 ÷ 16 = 1.5rem. The other way round you multiply: 2rem × 16 = 32px.

What is the difference between rem and em?

rem always refers to the font size of the html element, so it is the same everywhere on the page. em refers to the font size of the parent element and changes when elements are nested. For spacing and font sizes, rem is usually more predictable.

Why use rem instead of px at all?

When users set a larger default font in their browser, rem values grow with it, px values do not. Pages using rem stay more readable for people with low vision.

Should I convert media queries to rem too?

You can, and it is a good idea, but note: in media queries rem (like em) always refers to the browser’s font size, not to a root font size changed in your CSS. If you use html { font-size: 62.5% }, convert media queries with 16 as the base.