Web & CSS

PX to REM Converter

Convert px to rem and rem to px for any root font size, including the 62.5% setup. Convert a single value, a list, or a whole block of CSS, and build a fluid clamp() size. Everything runs in your browser.

Guide: PX to REM: Conversion Table, the 62.5% Trick and clamp()

Ready.

Convert many values or a CSS block

Fluid size with clamp()

Scales a size smoothly between two screen widths. Uses the root font size and decimal places set above.

Screen widthSize (px)Size (rem)

Common sizes

PixelsRem

What this tool does

It converts CSS lengths between pixels and rem. A rem is the font size of the root (html) element. Browsers set it to 16px by default, and users can change that default in their settings. The formula is rem = px ÷ root and px = rem × root, so at the default 24px is 1.5rem.

You can type one value, paste a list, or paste a block of CSS and convert every px length in it. The root size can be given in pixels or as a percentage of the 16px default, so the common 62.5% setup works directly. A separate helper builds a clamp() value for text that scales with the screen.

How to use it

  1. Set the root font size. Leave it at 16px unless your stylesheet changes the size of html. For the 62.5% setup choose the percent unit and enter 62.5.
  2. For one value, type pixels or rem in the pair of boxes at the top. The other box updates as you type.
  3. For many values, choose List of values and paste numbers. A bare number is treated as px (or rem if you picked rem to px). Values written with a unit, such as 1.5rem, are converted the other way in Auto mode. The output can be plain values, ready-made declarations such as font-size: 1.5rem;, or custom properties.
  4. For a stylesheet, choose CSS block, paste the CSS and copy the result. Check the notes shown under the output.

Common values

These are exact results for the two root sizes people use most. The table lower on the page follows whatever root size you set.

PixelsAt 16px (default)At 62.5% (1rem = 10px)
10px0.625rem1rem
12px0.75rem1.2rem
14px0.875rem1.4rem
16px1rem1.6rem
18px1.125rem1.8rem
20px1.25rem2rem
24px1.5rem2.4rem
32px2rem3.2rem
48px3rem4.8rem
64px4rem6.4rem

Converting a CSS block

The CSS mode scans the text and converts px lengths inside declarations, including inside calc() and shorthand values such as font: 12px/20px. It is a text scanner, not a full CSS parser, so it deliberately leaves some things alone:

  • Comments, quoted strings and url() contents are never changed.
  • Conditions in @media, @container, @supports and @import are left as written. The tool tells you when it skipped one.
  • Values of 1px and smaller (borders, hairlines, 0.5px details) stay in px by default. Untick the option to convert them too.
  • Only px (or rem in the reverse direction) is converted. Other units such as em, pt and vw are not touched, and values behind var() are not resolved.
  • It does not decide what should be relative. Read the result before you use it, especially shadows, transform distances and values that must stay fixed.

Once converted, run the stylesheet through the CSS Formatter & Minifier to tidy or compress it.

Which units to use where

UseGood fitWhy
remFont sizes, spacing, layout widths, breakpoints in @mediaFollows the user's default text size and keeps proportions consistent across the page.
emPadding and margins that should scale with a component's own font size, such as a buttonRelative to the element's own font size (or the parent's, when used on font-size), so nested values multiply.
pxBorders, hairlines, shadows, fixed icon bitmapsShould not change when text size changes.
%, vw, chFluid widths, line length (max-width: 65ch)Relative to the container, the viewport or the glyph width, not to the root size.

There is no single right answer. A common approach is rem for type and spacing, px for borders, and em where a component should scale as a unit.

The 62.5% root size

Some projects set html { font-size: 62.5%; } so that 1rem equals 10px and the arithmetic is easier: 14px becomes 1.4rem. It works because 62.5% of 16px is 10px. It also has costs:

  • Everything that inherits the root size becomes small, so the body needs font-size: 1.6rem to get back to a normal reading size.
  • Third-party components, embeds and browser defaults that assume 1rem is about 16px can look too small.
  • Anything built with the default in mind (including copied snippets) needs converting.

It is a convenience for the author, not a requirement. With a calculator like this one, keeping the default root and converting values is just as practical. If you do use it, enter 62.5 with the percent unit above and every result follows.

Why not set html font-size in pixels?

html { font-size: 16px; } looks harmless but it overrides the size the user chose in their browser settings, so people who raised their default text size no longer get it. Use a percentage (100%) or leave it unset. That keeps rem tied to the user's preference, which is the point of using rem. This is also why the root size field here accepts a percentage.

Breakpoints and media queries

In a media query, em and rem are resolved against the browser's initial font size, not against the font-size you set on html. So with a 62.5% root, @media (min-width: 48rem) is still 768px, not 480px. Converting breakpoints is optional; many teams use rem or em breakpoints so the layout changes when users enlarge text, and keep that rule in mind. This tool does not change media-query conditions, so you decide when to convert them. At the default size: 640px = 40rem, 768px = 48rem, 1024px = 64rem, 1280px = 80rem.

Fluid type with clamp()

The helper above builds clamp(min, preferred, max). The preferred value is a straight line through your two points: intercept + slope × 100vw. With 16px at 320px wide and 24px at 1280px wide, the size grows linearly between those widths and stays fixed outside them. The table shows the size at common widths so you can check the curve before you copy it.

The result keeps a rem term in the preferred value, not only vw. A size made only of viewport units does not respond to the user's text size settings in the same way, and it can be hard to enlarge by zooming, so it is better to avoid it for body text. Test the final result at your own breakpoints and with the browser's text size enlarged.

Accessibility notes

  • Text size. rem values grow when the user raises their default font size; px values do not. Zooming the whole page scales both.
  • Large text and contrast. WCAG treats 18pt (24px) regular or 14pt (about 18.66px) bold as large text, which has a lower contrast requirement. At a 16px root that is 1.5rem and about 1.167rem. Check the colors with the Color Contrast Checker.
  • Line height. Prefer a unitless line-height such as 1.5 over a fixed length, so it follows the font size. If the converter turns a px line height into rem, consider whether a unitless value is better.

Common mistakes

  • Using the wrong root size. If your design tokens come from a project with a 62.5% root, convert with 62.5%, not 16px.
  • Converting 1px borders. 1px is 0.0625rem, which can render differently at different zoom levels. Keep hairlines in px.
  • Rounding too early. 14px is exactly 0.875rem, but 13.33px at a 16px root is 0.8331rem; use enough decimals to keep the pixel result you want, and note that browsers do their own rounding at layout time. The notes under the output tell you when a value rounds to 0.
  • Mixing em and rem and expecting the same number. Nested em font sizes multiply; rem does not.
  • Pasting a whole stylesheet and shipping the result unread. Review shadows, transforms, media queries and anything defined in third-party CSS.
  • Assuming the converter knows your html font size. It cannot read your stylesheet; the root size is whatever you enter.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16px root, 24px ÷ 16 = 1.5rem.

How do I convert rem to px?

Multiply the rem value by the root font size. At 16px, 1.5rem × 16 = 24px. Choose rem to px in the direction menu to convert a list or a block of CSS.

What is 1rem in px?

It equals the font size of the html element. That is 16px in most browsers unless the user or your CSS changed it. The line under the root field shows what 1rem equals for the size you entered.

What is the difference between rem and em?

rem is relative to the root element and stays predictable. em is relative to the current element (or its parent, for font-size), so nested values compound.

Should I use rem for everything?

No. Use it for type and spacing where you want the layout to follow text size, and keep px for things such as borders. See the table of units above.

Privacy and local processing

This tool runs entirely in your browser. The values and CSS you paste are converted by JavaScript on this page and are not sent to a server. There is no account and nothing is stored.

Share this tool

Your data is not included in this link.