Developer tool

CSS Unit Converter

Convert px, rem, em, pt, vw, vh and percent with custom root and parent font sizes and viewport size, and read a handy conversion table.

Free, no sign-up. Runs in your browser; nothing is uploaded.

Convert

  • px
    24px
  • rem
    1.5rem
  • em
    1.5em
  • pt
    18pt
  • vw
    1.6667vw
  • vh
    2.6667vh
  • %
    150%

Context

rem base

em base

size that 100% means

Quick table (px)

pxrememptvw
80.50.560.5556
100.6250.6257.50.6944
120.750.7590.8333
140.8750.87510.50.9722
1611121.1111
181.1251.12513.51.25
201.251.25151.3889
241.51.5181.6667
281.751.75211.9444
3222242.2222
362.252.25272.5
402.52.5302.7778
4833363.3333
563.53.5423.8889
6444484.4444
724.54.5545
9666726.6667

How to use the css unit converter

Convert CSS units with the right context

Moving a design from pixels to rem, working out a fluid font size in vw or matching a print stylesheet in points all depend on a few base numbers. This converter lets you set them, so the answers match your site rather than a default.

How to use it

  1. Enter a value and choose its unit.
  2. Read the same length in px, rem, em, pt, vw, vh and percent. Each has a copy button.
  3. Adjust the context values if yours differ from the defaults.

The context values

  • Root font size is the html font size, normally 16px. It decides rem.
  • Parent font size decides em. Nested elements can change it, so use the size of the element you care about.
  • Viewport width and height decide vw and vh. Try common sizes like 375 wide for phones or 1440 for laptops.
  • % of is the pixel size that 100 percent stands for. For font-size it is the parent font size; for width it is the parent width.

Why use rem

Rem units scale with the user's browser font size setting, which is an accessibility feature. People with low vision often raise their default size, and layouts built with rem grow with them while pixel layouts do not. A common pattern is rem for font sizes and spacing, px for borders and fine details, and percentages or vw for fluid layouts.

Quick reference

  1. px to rem: divide by the root size.
  2. rem to px: multiply by the root size.
  3. pt to px: multiply by 4/3.
  4. vw to px: viewport width times the value divided by 100.

The table

The table at the bottom shows common pixel sizes from 8 to 96 in rem, em, pt and vw using your context values. Keep it handy when you build a type scale or spacing system, and change the root size to see how the whole scale shifts.

Frequently asked questions

How do I convert px to rem?

Divide the pixels by the root font size, which is 16 by default. 24px is 1.5rem. Change the root size field if your site sets html font-size differently.

What is the difference between rem and em?

rem is relative to the root (html) font size and stays predictable. em is relative to the parent element font size and compounds when nested.

What does vw mean?

1vw is one percent of the viewport width, so at 1440px wide 1vw is 14.4px. vh is the same for height. Set your own viewport size to see how values change.

How are percentages handled?

A percentage depends on the property. Enter the size that 100 percent represents in the "% of" field, for example the parent width or font size, to convert against it.

How many pixels is a pt?

In CSS 1pt is 1/72 of an inch and 1px is 1/96 of an inch, so 1pt equals 1.333px and 12pt equals 16px.

Is it all done locally?

Yes. The maths runs in your browser.