Skip to main content
Calnex LogoCalnex
design

PX to REM Converter

Convert between CSS pixels and rem units using a configurable root font size, with a copyable CSS declaration and a 1px–32px reference table.

Parameters

Results

Rem Value1rem
Other results (2)
CSS Code
font-size: 1rem; /* 16px */
Quick Reference (1px–32px)
px | rem
---|---
1 | 0.0625
2 | 0.1250
3 | 0.1875
4 | 0.2500
5 | 0.3125
6 | 0.3750
7 | 0.4375
8 | 0.5000
9 | 0.5625
10 | 0.6250
11 | 0.6875
12 | 0.7500
13 | 0.8125
14 | 0.8750
15 | 0.9375
16 | 1.0000
17 | 1.0625
18 | 1.1250
19 | 1.1875
20 | 1.2500
21 | 1.3125
22 | 1.3750
23 | 1.4375
24 | 1.5000
25 | 1.5625
26 | 1.6250
27 | 1.6875
28 | 1.7500
29 | 1.8125
30 | 1.8750
31 | 1.9375
32 | 2.0000

This converter turns a pixel value into rem, or a rem value into pixels, using the base font size you enter. It also produces a ready-to-paste CSS declaration and a fixed 1px–32px reference table computed at that same base.

Why does the reference table not change when I switch direction?

The table is always built as pixels to rem at your base font size, from 1px to 32px with four decimals. Switching to Rem → Pixels changes the main converted value and CSS output, but the table keeps its px-to-rem layout, so read it as a px lookup even in rem-to-px mode.

What happens if I enter 0 or leave a field blank?

The engine falls back to 16 for both Value and Base Font Size when the entered number is falsy, so a blank or zero Value is treated as 16 rather than 0 in either direction, including rem-to-px mode. Base Font Size has a minimum of 1 in the form, but the compute step itself only guards against falsy input, so rely on the form limits rather than expecting an error message.

How precise are the outputs?

Px-to-rem results are rounded to four decimal places and rem-to-px results to two, with trailing zeros removed. The CSS code uses the same rounded number as the displayed result, so the declaration and the text value always agree, but very small pixel values can round to 0rem.

Examples and interpretation (2)

How do I convert 24px to rem with the default 16px base?

Value
24
Base Font Size (px)
16
Conversion Direction
Pixels (px) → Rem
  1. Set Value to 24, Base Font Size to 16 and Direction to Pixels (px) → Rem.
  2. Divide 24 by 16 to get 1.5; the tool rounds to 4 decimals and displays 1.5rem with CSS font-size: 1.5rem; /* 24px */.
Rem Value
1.5rem
CSS Code
font-size: 1.5rem; /* 24px */

1.5rem scales with the root font size, so it grows or shrinks with user settings, unlike a fixed 24px. The CSS comment keeps the original pixel value for reference only.

How many pixels is 1.5rem when the root font size is 20px?

Value
1.5
Base Font Size (px)
20
Conversion Direction
Rem → Pixels (px)
  1. Set Value to 1.5, Base Font Size to 20 and Direction to Rem → Pixels (px).
  2. Multiply 1.5 by 20 to get 30; the tool rounds to 2 decimals and displays 30px with CSS font-size: 30px; /* 1.5rem */.
Rem Value
30px
CSS Code
font-size: 30px; /* 1.5rem */

The pixel result depends entirely on the base you supply; with the default 16px base the same 1.5rem would be 24px. The reference table still shows px-to-rem rows at the 20px base.

How to use

  1. Enter the Value to convert, in px or rem depending on the direction you will choose.
  2. Set Base Font Size (px); the default is 16, matching a typical browser root size.
  3. Choose Conversion Direction: Pixels (px) → Rem or Rem → Pixels (px).
  4. Read the converted result and copy the CSS Code declaration if you need it in a stylesheet.
  5. Check the Quick Reference table, which lists px 1–32 converted at your base font size.

Frequently asked questions

Does the tool use the browser's actual root font size?

No. It uses only the Base Font Size (px) you enter, defaulting to 16. If your page sets html { font-size } to something else, enter that value so the conversion matches your stylesheet.

Can I convert a rem value while the direction is still px-to-rem?

No. In px-to-rem mode the Value is treated as pixels and divided by the base. Switch Conversion Direction to Rem → Pixels (px) before entering a rem value, otherwise the result will be far smaller than expected.

Why does a small pixel value show 0rem?

Px-to-rem output is rounded to four decimals, so a pixel value below 0.00005 times the base rounds to zero. For example, 0.0005px at a 16px base becomes 0rem; use a larger unit or more precision outside this tool if you need that granularity.