>
B's Code

CSS Unit Converter

Convert between px, rem, em, pt, vw, and vh using a configurable base font size and viewport. Runs entirely in your browser.

[ VALUE ]
[ BASE ]

em uses the same base font size as rem — true em cascades through parent elements, which this tool can't see.

[ OUTPUT ]
px
16
rem
1
em
1
pt
12
vw
0.8333
vh
1.4815

About CSS Unit Converter

CSS length units are relative to different things — rem to the root font size, vw and vh to the viewport. Converting between them requires knowing those reference values, which you set here.

How to use it

  1. Set the base (root) font size — 16px by default.
  2. Set the viewport width and height if you need vw or vh.
  3. Enter a value in any unit.
  4. Read the equivalent in every other unit.

Frequently asked questions

What base font size should I use?
16px is the browser default. If you have changed the font-size on the root or html element, use that value.
How is em different from rem?
rem is always relative to the root font size. em is relative to the element's own font size, which varies by context — this tool uses the base value as an approximation.
Are the conversions exact?
px, rem, em, and pt conversions are exact for the base you set. vw and vh depend on the viewport size you enter.