CSS Unit Converter (px / rem / em)
Convert between px, rem, em and pt using a root font size.
About the CSS Unit Converter (px / rem / em)
Converts CSS length units between pixels, rem, em and points based on a chosen root font size (default 16px).
$$ rem = \frac{px}{root\ size} $$
How to use
Enter a value, its unit, the target unit and root font size, then click Convert.
Worked example
24px at 16px root = 1.5rem.
How to use this calculator
- Enter the value you want to convert.
- Choose the source unit and the target unit.
- Set the root font size, and set the current font size if you are converting em.
- Review the converted value and the formula shown by the tool.
The formula explained
$$ \text{px} = \text{rem} \times \text{root font size}, \quad \text{rem} = \frac{\text{px}}{\text{root font size}}, \quad \text{em} = \frac{\text{px}}{\text{current font size}}, \quad \text{pt} = \frac{\text{px}}{1.333333} $$
- \(\text{px}\) = Pixels, the CSS unit being converted from or to
- \(\text{rem}\) = Root em, based on the root font size
- \(\text{em}\) = Relative to the current element font size
- \(\text{pt}\) = Points, a print style unit
- \(\text{root font size}\) = The base font size used for rem conversion
- \(\text{current font size}\) = The element font size used for em conversion
Step by step method
- Identify which unit your starting value uses, such as px, rem, em, or pt.
- Decide what unit you want the result in.
- Use the root font size for rem conversions, and the current font size for em conversions.
- Read the converted value and check the worked example to confirm the calculation path.
Worked example
A designer wants to convert a 24 px heading into rem using a root font size of 16 px.
- Start with 24 px and the root font size 16 px.
- Use \(\text{rem} = \frac{\text{px}}{\text{root font size}}\), so \(\frac{24}{16} = 1.5\).
- The converted value is 1.5 rem.
Answer. 24 px = 1.5 rem
Tips and common mistakes
- Use the correct base size, because rem depends on the root font size and em depends on the current element size.
- Be careful when converting nested em values, since they can change with context.
- Check whether your project uses a root font size other than 16 px before converting.
- Treat pt as a separate print-style unit, not a direct design system default.
Frequently asked questions
What is rem based on?+
The root element's font size, usually 16px by default.
How is pt related to px?+
1pt = 1.333px at 96 DPI (the CSS reference).
More Tech Tools Tools
Explore related calculators in this category
CSS Gradient Generator
Generate CSS linear-gradient code from two colors and an angle.
AI API Cost Calculator
Estimate LLM API cost from input/output tokens and per-token prices.
Accessible Color Pair Finder
Check if a text/background pair meets WCAG and suggest a fix. Free tool with instant calculations, the underlying formula, and an easy-to-follow example.
Barcode Generator
Generate Code 128 / EAN barcodes from your data.
You Might Also Like
Popular tools from other categories
CSS Minifier
Minify CSS by removing comments, whitespace and the last semicolons. Shrink stylesheets instantly.
CSS Property Reference
Searchable reference of common CSS properties and what they do.
Unit Price Calculator
Compare products by price per unit.
.htaccess Generator
Generate common .htaccess rules, force HTTPS, www redirect, and caching, with checkboxes.
Can't Find the Right Calculator?
Try our AI Math Solver, type any problem in plain English and get instant step-by-step solutions.