๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

PX to REM Converter

Convert pixels to rem and rem to pixels for any root font size โ€” or paste a stylesheet to convert every px value at once.

24px = 1.5rem when the root font size is 16px.

Convert a stylesheet

Result

.card {
  padding: 1.5rem 2rem;
  font-size: 0.875rem;
  border: 1px solid #ddd;
  margin-bottom: 0;
}

Conversion table (16px root)

1px0.0625rem
2px0.125rem
4px0.25rem
6px0.375rem
8px0.5rem
10px0.625rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
28px1.75rem
32px2rem
36px2.25rem
40px2.5rem
48px3rem
56px3.5rem
64px4rem
72px4.5rem
80px5rem
96px6rem

When should you use the PX to REM Converter?

  • Turning pixel values from a design file into accessible rem units
  • Migrating an existing stylesheet from px to rem
  • Checking what a rem value equals in pixels

How to use the PX to REM Converter

  1. 1

    Set the root font size

    Leave it at 16px (the browser default) or enter your site's html font size.

  2. 2

    Convert a single value

    Type in the px box to get rem, or in the rem box to get px.

  3. 3

    Convert a whole stylesheet

    Paste CSS into 'Convert a stylesheet'. Every px value is replaced with rem.

  4. 4

    Copy the result

    Click Copy CSS to copy the converted stylesheet.

Examples

Converting CSS (16px root)

Before

.card {
  padding: 24px 32px;
  font-size: 14px;
  border: 1px solid #ddd;
}

After

.card {
  padding: 1.5rem 2rem;
  font-size: 0.875rem;
  border: 1px solid #ddd;
}

Common errors and how to fix them

Converted sizes look wrong on my site
Your site may change the root font size (for example html { font-size: 62.5% } makes 1rem = 10px). Set Root font size to match.
Media queries behave differently after converting
In media queries, rem and em are always based on the browser's default font size, not your html font-size rule.
Related tools:ย CSS Gradient Generator ยท Color Picker & Converter ยท CSS Minifier

More from Design & Color

Free tools that run in your browser โ€” no signup, nothing uploaded.

PX to REM Converter FAQ

Divide the pixel value by the root font size. With the default root size of 16px, 24px รท 16 = 1.5rem. To go back, multiply: 1.5rem ร— 16 = 24px.

It's the font size of the <html> element. Browsers default to 16px, but users can change it in their settings, and some sites set html { font-size: 62.5% } to make 1rem = 10px. Enter your site's value to convert correctly.

rem units scale with the user's browser font-size setting, so text and spacing grow for people who need larger text. That makes layouts more accessible than fixed pixels.

rem is relative to the root (<html>) font size everywhere on the page. em is relative to the font size of the current element, so it compounds when elements are nested.

Usually not. Hairline borders are meant to stay 1px at any text size, which is why the stylesheet converter keeps values of 1px or less by default. Untick the option to convert them too.

Yes. Paste CSS into 'Convert a stylesheet' and every px value is replaced with its rem equivalent. 0px becomes 0.