PX to REM Converter

Convert a single pixel value to rem (or back), or paste CSS and turn every px value into rem in one go. The default root font size is 16px, the browser default; change it if your site sets a different base.

px-to-rem · runs locally
⇄
5 values converted

How to use the px to rem converter

Type a pixel value to see it in rem, or type rem to see pixels; the other box updates as you type. Change the root font size if your site sets one on the html element. For a whole stylesheet, paste it into the left box: every px value is converted to rem on the right, with 1px borders left alone by default. Values are rounded to four decimal places, which is far finer than a screen can show.

PX to REM conversion table (16px base)

PixelsremTypical use
10px0.625remCaptions, labels, fine print
12px0.75remCaptions, labels, fine print
14px0.875remBody text
16px1remBody text
18px1.125remLead paragraphs, small headings, spacing
20px1.25remLead paragraphs, small headings, spacing
24px1.5remLead paragraphs, small headings, spacing
28px1.75remHeadings, section spacing
32px2remHeadings, section spacing
40px2.5remHeadings, section spacing
48px3remDisplay headings, large gaps
64px4remDisplay headings, large gaps

The 62.5% trick, and why it is falling out of favor

Setting html { font-size: 62.5%; } makes 1rem equal 10px, so 24px becomes an easy 2.4rem. It works, and it still respects user font-size preferences because it is a percentage. The catch is that every component then needs its own font size, since unstyled text inherits 10px, and third-party widgets that assume a 16px root come out tiny. With a converter at hand, keeping the default 16px root and dividing by 16 is usually less trouble.

For when to reach for px, rem, em or viewport units, read px vs rem vs em. To shrink the converted stylesheet for production, run it through the CSS Minifier, and check the text colors you are sizing with the Color Contrast Checker.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size. With the browser default of 16px, 24px ÷ 16 = 1.5rem, 12px = 0.75rem and 32px = 2rem. To go back, multiply: 1.25rem × 16 = 20px. If your stylesheet sets html { font-size: 62.5% }, the root is 10px and the math becomes 24px = 2.4rem.

What is the difference between rem and em?

rem is relative to the root element's font size, so 1rem means the same thing everywhere on the page. em is relative to the font size of the element itself (or its parent, when used for font-size), so it compounds: a 1.2em list inside a 1.2em list is 1.44 times the base. Use rem for consistent sizing and em when something should scale with its local text, such as padding on a button.

Why use rem instead of px?

Users can change the default font size in their browser settings, and rem-based font sizes follow that preference while px sizes ignore it. Browser zoom scales both, but the font-size setting does not. Sizing text in rem is one of the simplest ways to respect that accessibility setting.

Should borders and shadows be in rem too?

Usually not. A 1px border is meant to be a hairline at any text size, and converting it to 0.0625rem can render as 0 or 2 device pixels depending on zoom. Keep hairlines, box-shadow offsets and media query breakpoints you think of in pixels as px, and convert font sizes, spacing and layout widths.