Px to Rem Converter

Convert pixel values to rem (and back) instantly. Single-value calculator plus bulk CSS conversion. All in your browser.

px Default browser is 16px. Change if your CSS sets html { font-size: ... }.
Pixels
Rem
Bulk CSS Conversion

Paste a CSS block — every px (or rem) value will be converted using your root font size above.

Reference table — base 16px
PixelsRem

Quick answer

To convert px to rem, divide the pixel value by the root font size — rem = px ÷ 16 at the browser default. rem is preferred over px for font sizes and spacing because it scales with the user's browser font setting, which matters for accessibility. This tool does single values and whole CSS blocks in your browser, with a configurable root size — nothing is uploaded.

How the Conversion Works

The formula for both directions:

rem = px ÷ root_font_size
px  = rem × root_font_size

The browser default root font size is 16px, so 1rem = 16px. If your CSS sets html { font-size: 62.5%; }, the root becomes 10px and 1rem = 10px — change the root font size input above to match your project.

When to still use px

The 62.5% pattern

Setting html { font-size: 62.5%; } makes 1rem = 10px, so 1.6rem = 16px and 2.4rem = 24px — simpler mental math. If you use this pattern, set the body to font-size: 1.6rem so default text is still ~16px. Enter 10 in the root font size field above to use this pattern.

Worked example

Paste a CSS rule into the bulk converter (root font size 16) and every px value is divided by 16:

Input CSS

.card {
  padding: 24px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid #ccc;
}

Output CSS (px → rem)

.card {
  padding: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 0.0625rem solid #ccc;
}

What happened

Edge cases & gotchas

Frequently Asked Questions

What is the formula for converting px to rem?

rem = px ÷ root_font_size. The browser default root font size is 16px, so 24px ÷ 16 = 1.5rem. If you change the root font size with html { font-size: ... }, divide by that value instead.

Why use rem instead of px?

rem scales with the user's browser font size setting, which is critical for accessibility. A user who increases their browser font size to 20px (because they have low vision) will see your 1rem spacing grow proportionally; 16px spacing stays at 16px regardless.

What's the difference between rem and em?

em is relative to the parent element's font size. rem is relative to the root element's (html) font size. rem is more predictable because it has a single source of truth, while em compounds when nested.

Is my CSS sent to a server?

No. All conversion happens in your browser. Your CSS never leaves your device.

Does this work with Sass or SCSS?

Yes. Paste a Sass or SCSS block into the bulk converter — it operates on raw text and only touches numeric values immediately followed by px or rem. Variables, mixins, selectors, and comments are left untouched. Note that it converts every matching value, so a 1px border becomes 0.0625rem too; review the output if you want to keep some values in px.