PX to REM Converter
px ⇄ rem, em and every CSS length unit — or convert a whole stylesheet at once.
Settings
Convert a value
Type a number, or a number with its unit — 24, 24px, 1.5rem, 12pt.
| Unit | Value | Copy |
|---|
Reference table
Common sizes at a 16px root and 16px parent.
| 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
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.
Changes
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
- Check Root font size. Leave 16 unless your CSS sets the
htmlfont size — for examplehtml { font-size: 62.5% }makes it 10. - Type a value under Convert a value, such as
24,24pxor1.5rem. A unit you type selects the From unit automatically. - 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.
- 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
14px, 16px, 24px with a 16px root
0.875rem, 1rem, 1.5rem
rem = px ÷ root font size.
24px with html { font-size: 62.5% } (root 10px)2.4rem
12pt
16px = 1rem (at a 16px root)
1pt is 1/72 inch and 1px is 1/96 inch, so 12pt = 12 × 96 ÷ 72 = 16px.
.card { padding: 24px 16px; border: 1px solid #ddd; }
@media (min-width: 768px) { .card { padding: 32px; } }.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.4remvalue 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 setfont-size, and the element’s own font size for every other property. % here means a percentage of the parent font size, as infont-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, sop-4is 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
1cmwill rarely measure exactly 1 cm on your monitor. emand%use the single parent font size you enter; in a real page nestedemvalues 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.