Skip to content

PX to REM Converter

Convert pixels to rem and rem to pixels for CSS. This px to rem calculator divides by your root font size, which is 16px in most browsers by default.

Runs in your browser Free, no sign-up
Loading tool workspace...

What is PX to REM Converter?

This px to rem converter turns CSS pixel values into rem units and back. A rem is relative to the root font size, the font-size of the html element, which is 16px in every major browser unless the user or your stylesheet changes it. So 24px is 1.5rem and 12px is 0.75rem with the default root size.

Type in either the px or the rem box and the other updates instantly, together with a CSS rule you can paste into your stylesheet. You can change the root font size if your project sets one, for example 10px, and the reference table updates to match. To migrate a whole stylesheet, paste CSS into the snippet converter and every px value is rewritten in rem, or every rem value in px, while 1px borders can be kept as they are.

How to use PX to REM Converter

  1. Check the root font size; leave it at 16px unless your CSS sets a different html font-size.
  2. Type a pixel value such as 24 in the px box, or a rem value such as 1.5 in the rem box.
  3. Read the converted value (24px ÷ 16 = 1.5rem) and copy it or the generated CSS rule.
  4. To convert many values, paste CSS into the snippet converter, choose px → rem or rem → px, and copy the converted CSS.

Key features

  • Two-way conversion: px to rem and rem to px
  • Adjustable root font size (16px default)
  • Convert every px or rem value in a CSS snippet at once
  • Option to keep 1px borders in pixels
  • Ready-to-copy CSS rule and a px to rem chart from 1px to 64px
  • Runs entirely in your browser

Common use cases

  • Converting pixel values from a Figma or Sketch design into rem-based CSS
  • Building accessible typography and spacing scales
  • Migrating a stylesheet from px to rem units
  • Setting Tailwind or design-token values in rem
  • Checking what a rem value means in pixels for a given root size

Technical details & standards

The formulas are rem = px ÷ root font size and px = rem × root font size. With the default 16px root, 1px = 0.0625rem, 8px = 0.5rem, 14px = 0.875rem, 18px = 1.125rem and 32px = 2rem. Results are rounded to four decimal places.

The snippet converter rewrites every number followed by px (or rem) in the CSS, including negative and decimal values, shorthand properties and media queries, and leaves names that merely contain px, such as .mt-2px or var(--gap-4px), untouched. Zero becomes a unitless 0. Keep 1px leaves hairline borders in pixels, because a 0.0625rem border can render blurry or vanish at some zoom levels. Using rem for font sizes, spacing and layout means your interface scales when users raise their browser's default font size, an important accessibility setting that px values ignore.

PX to REM conversion table

Common pixel sizes in rem with the default 16px root, and with a 10px root for projects that set html { font-size: 62.5% }. Divide by your own root size for anything not listed.

Pixelsrem (16px root)rem (10px root)Typical use
1px0.0625rem0.1remHairline borders
2px0.125rem0.2remThin borders and focus rings
4px0.25rem0.4remSmallest spacing step
8px0.5rem0.8remBase unit of an 8-point spacing scale
10px0.625rem1remThe root size of the old 62.5% trick
12px0.75rem1.2remCaptions and fine print
14px0.875rem1.4remSmall body text and labels
16px1rem1.6remThe browser default root size
18px1.125rem1.8remComfortable body text
20px1.25rem2remLarge body text, small headings
24px1.5rem2.4remHeadings (h3, h4)
28px1.75rem2.8remHeadings (h2)
32px2rem3.2remHeadings (h1) and large spacing
40px2.5rem4remDisplay text
48px3rem4.8remHero headings and section spacing
64px4rem6.4remVery large display text

Frequently asked questions

How many pixels is 1rem?

16px by default, because browsers set the root font size to 16px. If your stylesheet changes the html font-size, 1rem equals that value instead, for example 10px with html { font-size: 62.5%; }.

How do I convert rem back to px?

Multiply by the root font size: 1.5rem × 16 = 24px. Type the rem value into the rem box and the pixel value appears next to it, or switch the snippet converter to rem → px for a whole stylesheet.

Should I use rem or px in CSS?

Use rem for font sizes and most spacing so the layout respects the user's font-size preference. px is still fine for things that should not scale with text, such as 1px borders and box shadows.

What is the difference between rem, em and px?

rem is relative to the root html element, so it means the same everywhere on the page. em is relative to the font size of the current element, so nested elements compound: 1.2em inside 1.2em is 1.44 times the root size. px is a fixed unit that does not change with the font size.

What is 20px in rem?

1.25rem with the default 16px root size (20 ÷ 16). Other common values: 12px = 0.75rem, 14px = 0.875rem, 18px = 1.125rem, 24px = 1.5rem and 32px = 2rem. Going the other way, 0.75rem = 12px, 1.25rem = 20px and 2.5rem = 40px.

How do I convert px to em?

Divide the pixel value by the font size the em is relative to: the parent's font size for the font-size property, and the element's own font size for everything else, such as padding. With a 16px font size, 24px is 1.5em. Set the root font size in this converter to that font size and the rem result is the em value.

How do I convert px to vw or vh?

vw and vh are percentages of the viewport: 1vw is 1% of its width and 1vh is 1% of its height, so vw = px ÷ viewport width × 100. 192px on a 1920px-wide screen is 10vw, and 54px on a 1080px-tall screen is 5vh. This converter handles px and rem only.

What is 18px in rem?

18px is 1.125rem with a 16px root font size.

What is 1px in rem?

1px is 0.0625rem with a 16px root font size.

What is the px to rem formula?

rem = px ÷ root font size. To go from rem to px, multiply the rem value by the root font size.

Is my data safe?

Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.

Does it work offline?

Once the page has loaded, this tool can process input without an internet connection.

More calculators tools

View all