ToolDash
PX to REM Converter

PX to REM Converter

Enter a pixel value to get rem, or a rem value to get pixels, based on whatever root font size your site uses. Paste a stylesheet to convert every px value at once.

  • Free, no sign-up
  • Runs in your browser — nothing is uploaded
  • Instant results, no waiting on a server

Convert pixels to rem and back using any root font size. Browsers default to 16px, so 1rem = 16px unless your CSS sets a different font-size on html.

Convert a value
px

The font-size on <html>. 16 is the browser default.

px
rem
24px = 1.5rem
px to rem tableroot 16px
pxrem
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

Convert a whole stylesheet

CSS input
Converted6 values converted
.card {
  padding: 1.5rem 2rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 0.0625rem solid #e5e7eb;
  border-radius: 0.75rem;
}

How to convert px to rem

  1. 1Set the Root font size. Leave it at 16 for the browser default, or pick 10, 14, 18 or 20, or type your own if your CSS sets font-size on the html element.
  2. 2Type a value into Pixels to see it in rem, or into REM to see it in pixels. Both fields accept a trailing unit, so 24px or 1.5rem work too.
  3. 3Use the px to rem table for common sizes from 1px to 96px, recalculated for your root size. Each row has a copy button.
  4. 4To convert a whole file of CSS px to rem (or back), paste it into the stylesheet converter, choose px → rem or rem → px, and copy the converted output.

Why rem, and how the math works

A rem is a multiple of the root element's font size. The formula is simply rem = px ÷ root size, and px = rem × root size. Every major browser ships with a 16px default, so 24px is 1.5rem and 14px is 0.875rem. If your stylesheet sets html { font-size: 10px }, then 1rem is 10px and 24px becomes 2.4rem, A rem calculator is only right if it uses your actual root size, which is why the root size is configurable here.

The reason to use rem at all is accessibility. When someone raises the default font size in their browser settings, anything sized in rem grows with it, while anything in px stays fixed. Sizing text, spacing and layout widths in rem keeps a page in proportion for people who need larger text. Media queries written in rem or em respond to that setting too.

em works the same way, except it's relative to the parent element's font size rather than the root, so values compound when elements are nested. This tool converts against the root; for em, enter the parent's font size as the root size.

The stylesheet converter finds numbers followed by px and replaces them using the current root size. It leaves 0px alone, skips values glued to identifiers such as a .grid-10px class name, and rounds to at most four decimal places. Hairline borders are a common exception, since 1px becomes 0.0625rem, which can render inconsistently at some zoom levels. Tick 'Keep 1px values as px' to leave them untouched.

When developers reach for it

Translating designs

Convert pixels to rem for values taken from a Figma or Sketch file, then use them in a stylesheet, Tailwind config or design tokens.

Migrating old CSS

Paste a legacy stylesheet that's full of px and convert it to rem in one pass to make the layout scale with user font settings.

Working with a 62.5% root

Projects that set html { font-size: 62.5% } make 1rem equal 10px. Set the root to 10 to get matching numbers.

Checking framework spacing

See what a framework's rem-based spacing scale means in pixels, for example that 0.25rem is 4px at the default root.

Frequently asked questions

How many pixels is 1rem?

+

16px by default in Chrome, Firefox, Safari and Edge. It changes if your CSS sets a different font-size on the html element, or if the user changes their browser's default font size.

What's the formula to convert px to rem?

+

Divide the pixel value by the root font size: 24 ÷ 16 = 1.5rem. To go back, multiply: 1.5 × 16 = 24px.

Should I use rem or px?

+

Use rem for font sizes, spacing and breakpoints so the layout respects the user's font-size preference. px is still fine for things that shouldn't scale, such as hairline borders or box-shadow offsets.

What's the difference between rem and em?

+

rem is relative to the root html element's font size. em is relative to the current element's parent font size, so em values multiply when elements are nested.

Does the stylesheet converter change anything except px?

+

No. In px → rem mode it only rewrites numbers followed by px; in rem → px mode it only rewrites numbers followed by rem. Colors, percentages, em and everything else are left as they are.