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
- px24px
- rem1.5rem
- em1.5em
- pt18pt
- vw1.6667vw
- vh2.6667vh
- %150%
Context
rem base
em base
size that 100% means
Quick table (px)
| px | rem | em | pt | vw |
|---|---|---|---|---|
| 8 | 0.5 | 0.5 | 6 | 0.5556 |
| 10 | 0.625 | 0.625 | 7.5 | 0.6944 |
| 12 | 0.75 | 0.75 | 9 | 0.8333 |
| 14 | 0.875 | 0.875 | 10.5 | 0.9722 |
| 16 | 1 | 1 | 12 | 1.1111 |
| 18 | 1.125 | 1.125 | 13.5 | 1.25 |
| 20 | 1.25 | 1.25 | 15 | 1.3889 |
| 24 | 1.5 | 1.5 | 18 | 1.6667 |
| 28 | 1.75 | 1.75 | 21 | 1.9444 |
| 32 | 2 | 2 | 24 | 2.2222 |
| 36 | 2.25 | 2.25 | 27 | 2.5 |
| 40 | 2.5 | 2.5 | 30 | 2.7778 |
| 48 | 3 | 3 | 36 | 3.3333 |
| 56 | 3.5 | 3.5 | 42 | 3.8889 |
| 64 | 4 | 4 | 48 | 4.4444 |
| 72 | 4.5 | 4.5 | 54 | 5 |
| 96 | 6 | 6 | 72 | 6.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
- Enter a value and choose its unit.
- Read the same length in px, rem, em, pt, vw, vh and percent. Each has a copy button.
- 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
- px to rem: divide by the root size.
- rem to px: multiply by the root size.
- pt to px: multiply by 4/3.
- 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.