CSS & Design Tools014

PX to REM Converter

Turn pixel values from a design file into rem units for your CSS, at the root font size your site actually uses.

02 — Result (rem)

—

Type a value in px

Swap: convert rem to px

Paste values to convert them all at once

Processed locally · 0 bytes sent

How to convert px to rem

  1. Type a pixel value in the Pixels box. The rem value appears below as you type, with the calculation that produced it.
  2. If your site sets a different root font size, enter it in Root font size. The default, 16px, is what browsers use unless you change it.
  3. To convert a list, paste one value per line into the Batch box. Each line gets its own result, and blank lines are skipped.
  4. Click Copy to put the result on your clipboard, or Download .txt to save the batch as a file.

Why use this tool

  • Turning a design file into CSS

    Design tools such as Figma measure type and spacing in pixels. Convert the 14px body text, 24px headings and 32px gaps to rem before they go into your stylesheet, so they scale with the reader’s font settings.

  • Moving a stylesheet from px to rem

    Refactoring an older codebase? Paste every pixel size the stylesheet uses into the Batch box and get the whole list back in rem, one line per value, ready to search and replace.

  • Building a type or spacing scale

    Design tokens and utility frameworks are usually defined in rem. Convert the pixel steps of your scale (4, 8, 12, 16, 24, 32…) and check that they come out as clean values.

  • Sites with a 62.5% root

    Some stylesheets set html { font-size: 62.5% } so that 1rem equals 10px. Set the root font size to 10 and the converter uses it; the link to the rem to px converter keeps it too.

Private by design

Every calculation runs in this browser tab, so results update the moment you change a value. There is nothing to upload, no account to create and nothing to install.

Good to know

The formula. rem = px ÷ root font size. With the default root of 16px, 24px ÷ 16 = 1.5rem. The root font size is the font-size of the html element: 16px in every major browser unless the user or your stylesheet changes it.

What you can type. Whole numbers, decimals, negative values and a decimal comma all work: 24, 24px, 13.5, 12,5 and -8. A comma is read as a decimal point, so type 1000, not 1,000, for a thousand. A value that ends in rem is already in rem, so it is flagged instead of being converted as if it were pixels. Results are rounded to at most four decimals, with trailing zeros dropped (0.09375rem shows as 0.0938rem). At a 16px root that rounding is under a thousandth of a pixel.

Batch mode. Paste one value per line. Every non-blank line gives one line of output in the same order. A line that is not a number becomes a CSS comment such as /* abc: Not a number */, so you can see what failed and still paste the result into a stylesheet.

Sharing a root font size. A root font size other than 16 is added to the address, for example ?base=10, so a link opens the converter with the same setting. The values you type never go in the address.

One catch with media queries. Inside a media query, rem is based on the browser’s default font size, not on the font size your stylesheet sets on html. With a 62.5% root, @media (min-width: 40rem) still means 640px at default settings, not 400px.

Example

In — Batch, root font size 16px

12
14px
18
24
2rem

Out — rem values, one per line

0.75rem
0.875rem
1.125rem
1.5rem
/* 2rem: Already in rem */
px to rem at a 16px root font size
pxrem
1px0.0625rem
2px0.125rem
3px0.1875rem
4px0.25rem
5px0.3125rem
6px0.375rem
7px0.4375rem
8px0.5rem
9px0.5625rem
10px0.625rem
11px0.6875rem
12px0.75rem
13px0.8125rem
14px0.875rem
15px0.9375rem
16px1rem
17px1.0625rem
18px1.125rem
19px1.1875rem
20px1.25rem
21px1.3125rem
22px1.375rem
23px1.4375rem
24px1.5rem
25px1.5625rem
26px1.625rem
27px1.6875rem
28px1.75rem
29px1.8125rem
30px1.875rem
31px1.9375rem
32px2rem
33px2.0625rem
34px2.125rem
35px2.1875rem
36px2.25rem
37px2.3125rem
38px2.375rem
39px2.4375rem
40px2.5rem
41px2.5625rem
42px2.625rem
43px2.6875rem
44px2.75rem
45px2.8125rem
46px2.875rem
47px2.9375rem
48px3rem
49px3.0625rem
50px3.125rem
51px3.1875rem
52px3.25rem
53px3.3125rem
54px3.375rem
55px3.4375rem
56px3.5rem
57px3.5625rem
58px3.625rem
59px3.6875rem
60px3.75rem
61px3.8125rem
62px3.875rem
63px3.9375rem
64px4rem

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size. At the default root of 16px, 24px is 24 ÷ 16 = 1.5rem and 12px is 0.75rem. If your site sets another root size, divide by that number instead; the Root font size box does this for you.

What root font size should I use?

Use the font-size your stylesheet sets on the html element. If it sets none, use 16, the default in every major browser. If it sets 62.5%, use 10. If it sets a percentage, multiply 16 by it: 112.5% is 18px.

Why use rem instead of px?

Sizes in rem follow the reader’s browser font size setting. Someone who raises their default font size for readability gets larger text and spacing on your site, while sizes in px stay fixed. Browser zoom scales both, but the font size setting only scales rem and em.

What is the difference between rem and em?

rem is relative to the root (html) font size, so 1.5rem means the same size everywhere on the page. em is relative to the font size of the element itself, which it inherits from its parent, so nested em values compound. rem is easier to predict for most sizes.

Why does my result have four decimals?

Some pixel values do not divide evenly by the root size. 1.5px at 16px is 0.09375rem, which the converter rounds to 0.0938rem. At a 16px root, four decimals keep the error below a thousandth of a pixel, far smaller than anything a screen can show.