PX to REM Converter
Type a value, choose whether it is in pixels, rem or em, and read the other two units for your base font size, 16 pixels unless you change it. Set the base to 10 if your stylesheet uses a 62.5 percent root size. A table gives the rem value of common sizes from 8 to 72 pixels, and a list mode converts a whole batch of values at once, for example everything you pasted from a design file. The calculation runs in your browser.
24px with a base of 16px
24px = 1.5rem
Pixels
24pxrem
1.5remem (parent = base)
1.5emCommon sizes
| px | rem / em |
|---|---|
| 8px | 0.5rem |
| 10px | 0.625rem |
| 12px | 0.75rem |
| 14px | 0.875rem |
| 16px | 1rem |
| 18px | 1.125rem |
| 20px | 1.25rem |
| 24px | 1.5rem |
| 28px | 1.75rem |
| 32px | 2rem |
| 36px | 2.25rem |
| 40px | 2.5rem |
| 48px | 3rem |
| 56px | 3.5rem |
| 64px | 4rem |
| 72px | 4.5rem |
Convert a list
How it works
- Enter the base font size in pixels. 16 is the usual browser default; use 10 if your root font size is 62.5 percent.
- Type your value and choose its unit: px, rem or em, then read the three results.
- Use the table to pick the rem value of a common pixel size without typing.
- For many values, paste them in list mode, choose the output unit and copy the converted list.
What people use it for
Moving a design to relative units
Turn 14, 18 and 24 pixel sizes from a mockup into rem values that follow the user's font setting.
Checking a 62.5 percent root
Set the base to 10 and see that 14 px is 1.4 rem, then compare with the same value at 16.
Converting a pasted list
Paste a column of pixel values and copy back the same list in rem.
Questions
- What is the formula?
- rem = px ÷ base and px = rem × base, where the base is the font size of the root element. With a base of 16, 24 px is 1.5 rem and 0.75 rem is 12 px; with a base of 10, 14 px is 1.4 rem. Results are rounded to at most 4 decimals, with no useless trailing zeros.
- What is the difference between rem and em?
- According to MDN, rem is relative to the font size of the root element, while em is relative to the font size of the element it is used on (for the font-size property, the parent's font size). They give the same number here because this page uses one base for both: for em, the base stands for the font size of the parent element. Nested elements with their own sizes make em values compound, which rem avoids.
- Why use rem instead of px?
- A rem length follows the root font size. When that size comes from the browser's default or from a setting the visitor changed, text sized in rem scales with it, while text fixed in px does not. Most browsers default to 16 px, but a visitor can change it, and a stylesheet can override it, which is why the base on this page is editable.
- How does list mode read my values?
- Values are split on spaces, commas, semicolons and line breaks. Each one is a number with an optional px, rem or em unit; a number alone uses the unit you choose for unitless values. Use a point for decimals (1.5rem, not 1,5rem). A value that cannot be read is flagged on its own row and the others are still converted. Up to 500 values at a time.