Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

PX to REM Converter

px ⇄ rem, em and every CSS length unit — or convert a whole stylesheet at once.

Design No upload Works offline Free, no sign-up

Settings

px
The html font size. 16 in every browser by default; 10 with 62.5%.
px
Used for em and %.
px
px

Convert a value

Type a number, or a number with its unit — 24, 24px, 1.5rem, 12pt.

In rem 1.5rem 24px ÷ 16px root
The value in every CSS length unit
UnitValueCopy

Reference table

Common sizes at a 16px root and 16px parent.

Common pixel sizes in rem, em and pt
px rem em pt Tailwind spacing
1px
2px
4px
6px
8px
10px
11px
12px
13px
14px
15px
16px
18px
20px
22px
24px
28px
30px
32px
36px
40px
44px
48px
56px
60px
64px
72px
80px
96px
112px
128px

Convert a stylesheet

Direction
px
Smaller values, like 1px borders, stay in px.
Comma-separated; * matches anything.

In @media, rem always means the browser’s default 16px, so media queries are converted at 16px whatever the root size; @container queries use the root size.

Next steps

About the PX to REM Converter

Type a length such as 24px and see it in rem, em and every other CSS length unit at once — %, pt, pc, in, cm, mm, Q, vw, vh, vmin and vmax. Set the root font size (16 px in every major browser unless the user or your CSS changes it), the parent font size that em and % depend on, and the viewport size for the viewport units. A reference table lists the common sizes, with the matching Tailwind CSS spacing number.

To convert a whole file, paste your CSS under Convert a stylesheet. Every px value in a declaration becomes rem, while 1px hairlines, media queries, selectors, comments, strings and url() paths stay exactly as they were. The rest of the file — formatting, comments and order — is not touched, and nothing leaves your browser.

How to use it

  1. Check Root font size. Leave 16 unless your CSS sets the html font size — for example html { font-size: 62.5% } makes it 10.
  2. Type a value under Convert a value, such as 24, 24px or 1.5rem. A unit you type selects the From unit automatically.
  3. Read the result in rem (or in px when you start from another unit) and the full list of units below it. Select Copy next to any value.
  4. For a stylesheet, paste it under Convert a stylesheet. Adjust the minimum px value, the properties to skip and whether media queries should change, then copy or download the converted CSS.

Examples

Common font sizes
Input
14px, 16px, 24px with a 16px root
Result
0.875rem, 1rem, 1.5rem

rem = px ÷ root font size.

With the 62.5% root
Input
24px with html { font-size: 62.5% } (root 10px)
Result
2.4rem
Print sizes
Input
12pt
Result
16px = 1rem (at a 16px root)

1pt is 1/72 inch and 1px is 1/96 inch, so 12pt = 12 × 96 ÷ 72 = 16px.

A stylesheet
Input
.card { padding: 24px 16px; border: 1px solid #ddd; }
@media (min-width: 768px) { .card { padding: 32px; } }
Result
.card { padding: 1.5rem 1rem; border: 1px solid #ddd; }
@media (min-width: 768px) { .card { padding: 2rem; } }

The 1px border and the 768px breakpoint are left alone by default.

Common uses

  • Moving a design from Figma or Sketch, which measure in pixels, to a rem-based stylesheet.
  • Converting an older stylesheet to rem so text follows the visitor’s browser font-size setting.
  • Checking what a 2.4rem value means on a site that uses the 62.5% root trick.
  • Turning print measurements in pt, mm or cm into CSS pixels, or pixels into vw for fluid layouts.

The formulas

The tool uses the definitions in CSS Values and Units Level 4:

  • Absolute units: 1in = 2.54cm = 96px = 72pt = 6pc, and 1cm = 10mm = 40Q. So 1pt = 4/3 px and 1mm ≈ 3.7795px.
  • rem = the font size of the root (html) element. em = the font size of the parent element when you set font-size, and the element’s own font size for every other property. % here means a percentage of the parent font size, as in font-size: 150%.
  • vw / vh = 1% of the viewport width / height; vmin and vmax use the smaller or larger of the two.
  • Tailwind spacing: Tailwind CSS v4 spacing utilities are multiples of --spacing: 0.25rem, so p-4 is 1rem — 16px at the default root size.

Why rem instead of px?

Browsers let people choose a larger default text size. Font sizes set in rem (or em) grow with that setting; font sizes in px do not, although page zoom still enlarges them. Using rem for text, and usually for spacing too, keeps layouts in proportion for people who need bigger text — see WCAG’s Resize Text requirement.

Thin lines are the usual exception: a 1px border written as 0.0625rem becomes thicker when the text size grows. That is why the stylesheet converter keeps values below 2px as they are (you can change the minimum).

Media queries are different

In a media query, rem and em always refer to the browser’s initial font size — 16px unless the visitor changes it — and ignore any font-size you set on html (Media Queries Level 4). So 768px and 48rem are the same breakpoint even on a site with the 62.5% root, where 76.8rem would move it to 1229px. The converter leaves @media and @container conditions alone unless you switch that on; when you do, media-query lengths are always converted at 16px, whatever root size you enter. Container queries are evaluated on the container instead, so rem there is the root font size and @container lengths use your root size.

Limitations

  • The stylesheet converter changes px to rem (or back) only; it cannot convert to em because em depends on where each rule ends up in the page.
  • Values in selectors, strings, comments, url() and custom property names are never changed. Very unusual syntax may be left as it is.
  • On screens, CSS inches and centimeters are tied to the CSS pixel, not to a ruler, so 1cm will rarely measure exactly 1 cm on your monitor.
  • em and % use the single parent font size you enter; in a real page nested em values multiply.

Privacy

Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size: rem = px ÷ 16 at the default root, so 24px = 1.5rem and 14px = 0.875rem. To go back, multiply: 1.25rem × 16 = 20px.

What is the root font size?

It is the font-size of the html element. Every major browser uses 16px unless the visitor changes the default text size or your CSS sets html { font-size: … }. If your CSS uses 62.5%, enter 10.

What is the difference between rem and em?

rem is always relative to the root font size, so 1rem is the same everywhere on the page. em is relative to the parent’s font size (for font-size) or the element’s own font size (for padding, margins and so on), so em values multiply when elements are nested.

Should borders and shadows be in rem?

Most people keep 1px borders in px so they stay hairlines when text is enlarged, which is why values below 2px are kept by default. For shadows and outlines, add them to Skip properties (for example *-shadow, outline) if you want them to stay in px too.

What does “Keep PX / Px as written” do?

CSS units are case-insensitive, so 16PX means 16px. Writing a unit in upper case is a common way to tell px-to-rem tools such as postcss-pxtorem to leave a value alone. With this option on, those values are skipped.

Is my CSS uploaded anywhere?

No. All conversion happens in your browser, and the page keeps working offline once it has loaded.

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.