Skip to content
Back

PX to REM Converter

Convert pixels to rem and rem to pixels using any root font size.

The font size of the html element. Browsers default to 16 px.

Common sizes at 16 px

pxrem
10px0.625rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
32px2rem
40px2.5rem
48px3rem
64px4rem

Convert CSS

as px (so 1px borders stay; 0 converts everything)

Turn pixel sizes into rem units for your CSS

PX to REM Converter works out rem values from pixels, and pixels from rem, for whatever root font size your site uses. Alongside the two linked boxes there is a table of common sizes and a Convert CSS box that rewrites every px value in a pasted stylesheet as rem.

Everything is calculated in your browser as you type. The CSS you paste is not uploaded or stored.

How to convert px to rem

  1. Check Root font size. It starts at 16 px, the default in every major browser; change it if your stylesheet sets a different size on the html element.
  2. Type a pixel value into Pixels to get rem, or a rem value into REM to get pixels. The box you didn’t type in updates straight away.
  3. Use the copy button next to either box to copy the value with its unit, such as 1.5rem.
  4. To convert a whole stylesheet, paste it into Convert CSS, adjust the options, and press Copy CSS.

How values are rounded and what the CSS converter changes

  • Rounding: results have at most four decimal places with trailing zeros removed, so 10 px at 16 px is 0.625rem and 10 px at 15 px is 0.6667rem.
  • Reference table: eleven common sizes from 10 px to 64 px, recalculated whenever you change the root size.
  • What gets converted: numbers followed by px in property values, including negatives (−8px), decimals (.5px) and several values on one line. 0px becomes 0, or 0rem inside calc() and custom properties, where a unitless zero would break.
  • What is left alone: comments, quoted strings, anything inside url(…), selectors (such as .mt-10px), and other units like %, em and vh.
  • Small values: anything below the “Keep values below” size (2 px by default) stays in px, so hairline borders remain exactly one device-independent pixel. Set it to 0 to convert everything.
  • Status line: counts how many values were converted, how many small ones were kept and how many were left in @media conditions.

Who uses a px to rem converter

  • Front-end developers: turn pixel values from a design file into rem so text and spacing scale with the reader’s font settings.
  • Refactoring old CSS: move a legacy stylesheet from px to rem in one paste, then review the result before committing it.
  • Design handoff: agree a spacing scale with designers by sharing the table for your root size.

rem, em and media queries

rem vs em

A rem is relative to the root font size — the size set on the html element — so 1.5rem means the same thing everywhere on the page. An em is relative to the font size of the element itself (or its parent, when used for font-size), so it compounds when elements are nested: a 1.2em list inside another 1.2em list ends up 1.44 times the base size.

That predictability is why rem is the usual choice for font sizes and spacing, while em suits things that should grow with their own text, such as the padding inside a button.

Why @media conditions stay in px by default

Inside a media query, rem and em don’t look at your html element at all. They use the browser’s default font size, normally 16 px, which the reader can change in their settings. So if your root size is 10 px, a 768 px breakpoint is 48rem in a media query, not 76.8rem.

For that reason the converter leaves media conditions in px unless you tick “Also convert @media conditions”. When you do, it always divides by 16, whatever root size you’ve entered. Values inside the rules of a media block are still converted with your root size as normal.

The 62.5% root size

Some stylesheets set html { font-size: 62.5% } so that 1rem equals 10 px with the default browser setting, which makes the arithmetic easy. If yours does, enter 10 as the root font size.

PX to REM Converter: common questions

What root font size should I use?

Use 16 unless your CSS sets a font size on the html element. With html { font-size: 62.5% } use 10; with a fixed value such as 18px use 18.

Why did my 1px border stay in px?

By default, values below 2 px are kept as px so thin borders and outlines don’t turn into fractions of a rem. Change “Keep values below” to 0 to convert them too.

Will it change pixel values inside image URLs or content strings?

No. Anything inside url(…), single or double quotes, or a comment is copied unchanged, as are selectors such as .mt-10px.

Can it handle SCSS or Less?

Often, as long as the px values sit in ordinary property: value declarations. Mixins, functions and variables are not understood, so check the output before using it.

Does it convert em, pt or other units?

No. It only converts px to rem, and rem back to px in the linked boxes. For general measurements, the Unit Converter covers length, weight and more.