Px to REM Converter with Bulk CSS Mode

Convert a single value between px and rem, or paste CSS and replace every px value with rem. The base font size defaults to 16 px and can be changed.

(browser default is 16)

Px to REM Conversion Table (Base 16px)

pxrem
4px0.25rem
8px0.5rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
32px2rem
40px2.5rem
48px3rem
56px3.5rem
64px4rem
80px5rem
96px6rem

Related Developer Tools

Runs in your browser: your files and text are not uploaded. Free, no account needed.

Last updated: · Reviewed by the QuickTooly Team

How px and rem relate

The Formula

rem = px / base, and px = rem × base. The base is the font size of the root html element. Browsers default it to 16 px, but a user's font size setting or a root font-size rule in your CSS changes it. Results are rounded to four decimal places.

Worked example: 24 px

With the default base, 24 / 16 = 1.5, so 24px becomes 1.5rem. With the base set to 10, the same 24 px becomes 2.4rem. Going back at base 16, 0.875 × 16 = 14, so 0.875rem is 14px.

How Bulk Conversion Works

Bulk mode finds every number directly followed by px and divides it by the base. Everything else is left as it is. That has a few consequences:

  • Every px is converted. That includes 1 px borders, which become 0.0625rem at base 16, and media query widths. Change back any you want to keep in px.
  • Media queries ignore your root font size. rem inside a media query refers to the browser's initial font size, not to an html font-size rule. If your base is not 16, a converted breakpoint can move.
  • Names are not skipped. A class name such as .mt-10px is converted too, which breaks the selector.
  • Lowercase px, one direction. 12PX is not matched, and bulk mode only converts px to rem.

Px and REM Questions

Should I use rem or em?

rem is always relative to the root font size, so 1.5rem is the same size everywhere on the page. em is relative to the font size of the current element, so nested em values multiply. This tool converts to rem only.

Why does html { font-size: 62.5% } mean a base of 10?

62.5% of the 16 px browser default is 10 px. Enter 10 as the base so 24px converts to 2.4rem. If a user changes their browser font size, the real base changes with it.

Are negative values converted?

Yes. In bulk mode the minus sign stays in place, so margin: -8px becomes margin: -0.5rem at base 16.

Related CSS Tools

  • CSS Formatter: tidy or minify the stylesheet after converting it.
  • Contrast Checker: check text contrast; WCAG counts text of 24 px (1.5rem at base 16) or more as large.