PX to REM Converter

Convert between px and rem with a configurable root size.

Convert pixel values to rem and back using a base font size you choose, and convert every px value inside a whole CSS snippet in one go. It helps front-end developers move fixed-pixel designs to scalable rem units that respect the user's browser font settings. The default base is 16px.

What is a rem unit?

A rem is a CSS length unit equal to the computed font size of the root element, which is the html element. Browsers default that size to 16px, so 1rem is 16px, 1.5rem is 24px and 0.875rem is 14px. Because rem scales with the root size, layouts built in rem grow or shrink when a user raises or lowers the default font size in their browser, which is good for accessibility. Unlike em, rem does not compound through nested elements, so values stay predictable. Converting is simple division: rem equals pixels divided by the root font size, and pixels equal rem multiplied by it.

How to use PX to REM Converter

  1. Set the base Enter the root size in Base font size (px). It must be greater than 0.
  2. Convert single values Type in Pixels to see REM, or type in REM to see Pixels. The other field updates as you type.
  3. Convert a snippet Paste CSS into CSS with px and read the converted code in CSS with rem.
  4. Copy the result Copy the output box content into your stylesheet.

Frequently asked questions

Why is 1px not converted?

Values of exactly 1px (or -1px) are left as they are in the snippet converter because thin borders and hairlines usually should stay one device-independent pixel wide. Convert those by hand using the Pixels field if you really want rem.

What base should I use?

Use the computed font size of your html element. Browsers default to 16px. If your CSS sets html to 62.5%, the effective base is 10px.

How precise are the results?

Values are rounded to four decimal places, for example 10px at base 12 becomes 0.8333rem. That is far more precise than browsers can render.

Does it convert em, vw or other units?

No. Only values written as a number followed by px are converted, and only px and rem are handled by the single-value fields.

Does it handle px inside media queries?

The snippet converter replaces every number followed by px anywhere in the text, including media queries, so review those results, since many teams keep breakpoints in px or em.