PX, REM and EM Converter

Convert CSS px, rem, and em in either direction. Edit any value, set the root and reference font sizes, and copy the result as a CSS length.

CSS values

Edit any field to update the other two.

Reference font sizes

Sets the size of 1 rem.

Use the font size that em is relative to in your CSS.

Convert between px, rem, and em

Edit any of the three fields to convert the other two. Set the reference font sizes to match the stylesheet you are working on. The last value you edited stays fixed when you change a reference size. Use the copy button beside a result to get a CSS length such as 1.5rem.

Use the root font size for rem

In most CSS declarations, rem is relative to the font size of the root element, usually html. With a root font size of 16px, 1rem equals 16px and 24px equals 1.5rem. Set the root field to the computed font size used by your page.

Choose the right font size for em

When you set font-size in em, use the inherited font size as the reference. For properties such as padding or margin, use the element’s own computed font size. With a reference of 20px, 1.2em equals 24px. The em and rem reference sizes can differ in the same layout.

Check the conversion formula

To convert from pixels, divide by the corresponding reference size. To convert back to pixels, multiply by that size. For example, a length of 24px becomes 1.5rem with a 16px root and 1.2em with a 20px reference. Here px means a CSS pixel. Fractional and signed lengths are supported where your CSS property accepts them.