PX to REM converter
Convert between px, rem, em, pt and percent in one step, with a base font size you can change. A reference table for 8px to 64px is included. Free, and it runs in your browser.
How to use it
- Type a number in Value and choose the unit in Convert from.
- Change the Base font size (px) if your root font size is not 16px.
- Read the result in every unit, or look up common sizes in the reference table.
Complete guide to converting px to rem, em and pt
Why CSS has so many size units
A pixel is a fixed unit, while rem and em scale with font size. That difference matters for accessibility: when a visitor raises the default text size in the browser, sizes written in rem grow with it, and sizes written in px do not. Designers usually deliver mockups in px, developers often want rem, and print stylesheets use pt. This converter moves between all of them in one step, using a base font size that you control.
The units in short
| Unit | Relative to | Typical use |
|---|---|---|
| px | Nothing (1/96 of an inch in CSS) | Borders, shadows, fixed details |
| rem | Font size of the root (html) element | Font sizes, spacing, layout |
| em | Font size of the parent element | Components that scale with their own text |
| pt | Absolute: 1pt = 1/72 inch | Print stylesheets |
| % | Base font size (for font-size) | Scaling relative to the parent |
How the conversion works
Everything is first turned into pixels and then into the other units. With the base size B, the formulas are: rem = px / B, px = rem x B, pt = px x 0.75 (so px = pt x 4/3), and percent = rem x 100. The tool shows em with the same number as rem, because it assumes the parent element has the base size. Results are rounded to four decimals, so a 1px value on a base of 3 shows 0.3333 rem. Everything runs in your browser and nothing is sent anywhere.
Worked examples
- Leave Convert from on px, type 24 in Value and keep Base font size (px) at 16. The tool shows 1.5 rem, 1.5 em, 18 pt and 150 %.
- Choose pt (points) and type 12. The result is 16 px and 1 rem, which is why 12pt is the usual browser text size.
- Choose rem, type 2.5 and set the base to 10. The result is 25 px, 18.75 pt and 250 %.
The reference table below the result shows common sizes for the base you chose. With a base of 16:
| px | rem | pt |
|---|---|---|
| 12 | 0.75 | 9 |
| 16 | 1 | 12 |
| 20 | 1.25 | 15 |
| 24 | 1.5 | 18 |
| 32 | 2 | 24 |
| 48 | 3 | 36 |
Tips and common mistakes
- Check your real base. If your CSS sets
html { font-size: 62.5% }, the root is 10px, so enter 10 in Base font size (px). Using 16 there gives wrong numbers. - Prefer rem for font sizes. Setting the root to a fixed px value in your CSS defeats the user's browser text preference.
- em compounds when nested: an element at 1.2em inside a parent at 1.2em ends up at 1.44 times the base. The tool cannot see your nesting, so for em inside nested elements use the parent size as the base.
- Borders and hairlines are usually better left in px, since they should not grow with text.
Related tools
To make a size that scales smoothly between two screen widths, try the CSS clamp generator. After converting, tidy your stylesheet with the CSS beautifier or shrink it with the CSS minifier.
Questions
How do I convert px to rem?
Divide the pixels by the base font size. With the usual 16px base, 24px is 24 / 16 = 1.5rem.
What is the difference between rem and em?
rem is relative to the root font size, while em is relative to the font size of the parent element. With the same base they give the same number, but em can compound when nested.
How are pt and px related?
In CSS, 1pt equals 1/72 of an inch and 1px equals 1/96 of an inch, so 1pt = 1.3333px and 12pt = 16px.
What base should I use?
Use 16, the browser default, unless your CSS sets a different font size on the html element. Some people set it to 62.5% (10px) to make rem math easier.