px to rem Converter

Type the size you want, such as 18px or 1.5rem, and see it in px, rem and em. Change the root size if your CSS changes it.

How it works

One rem is the font size of the root element, html. Browsers set it to 16px unless the reader or your CSS changes it. So rem is pixels divided by the root size: 18 divided by 16 is 1.125rem.

One em is the font size of the element the value sits in. When that element inherits the root size, em and rem agree. When a parent sets its own size, em is measured against the parent instead.

Type a number with px, rem or em, and the page shows all three. Nothing leaves your browser.

How to use it

  1. 1 Type a size with its unit, such as 18px, 1.5rem or 2em. A bare number is read as pixels.
  2. 2 Leave the root size at 16 unless your CSS sets a font size on html.
  3. 3 For em, type the font size of the parent element if it differs from the root.
  4. 4 Copy the value you need, or read it from the table of common sizes below.

Good to know

  • Write font sizes in rem. A reader who sets a larger default font in the browser then gets larger text, which px font sizes ignore.
  • Media queries in rem or em are measured against the browser default size, not against a font size you set on html.
  • Some sites set html { font-size: 62.5% } so that 1rem is 10px and the sums are easy. That still respects the reader setting, because it is a percentage.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Converting a design from pixels to rem, one component at a time

Design files are drawn in pixels, but CSS that respects the reader is written in rem. The sums are simple division, and the real work is knowing which number to divide by. Take a card from a design file with a 24px title, 16px body text, 14px caption and 20px padding, on a site that keeps the browser default root size of 16px.

Each value is divided by 16. The title is 24 divided by 16, which is 1.5rem. The body text is 1rem. The caption is 14 divided by 16, which is 0.875rem. The padding is 20 divided by 16, which is 1.25rem. Type each pixel value into the box above, or read it from the table, and you have the whole card. If the design system sets html { font-size: 62.5% }, the root is 10px, and the same title becomes 2.4rem.

Now a reader opens the browser settings and sets the default font size to 20px. Every rem value grows by a quarter. The title becomes 30px, the body 20px and the padding 25px, so the card keeps its shape and is easier to read. Had the card been written in px, the text would have stayed at 16px and only page zoom could help. That is the practical reason to convert, and it is also why it is fine to leave a 1px border in px.

em is the unit to reach for when a value should follow the text it sits next to. An icon sized at 1em is always as tall as the letters beside it, whether it sits in a 14px caption or a 24px heading. The cost is compounding. Inside the 24px title, 0.5em of padding is 12px, not 8px. That is why this page has a separate box for the parent size: em is only predictable once you know what it is measured against.

The converter has limits. It does not read your stylesheet, so it cannot know the real root or parent size; it uses the numbers you type. It rounds to four decimal places, which is far below a visible difference. It does not convert percentages, viewport units or line heights; the Viewport Unit Calculator handles vw and vh. And a browser may still round a fractional pixel size when it draws text, so 0.8125rem and 13px can render identically.

Frequently asked questions

How many pixels is 1rem?

16 pixels in a browser with default settings. It is whatever the root font size is, so if your CSS sets html { font-size: 20px }, 1rem is 20px. If the reader raises the default font size, 1rem grows with it.

What is the difference between rem and em?

rem is always measured against the root element. em is measured against the current element, which inherits from its parent. Nest three lists that each set font-size: 0.875em and the innermost text is 0.875 × 0.875 × 0.875 of the outer size. With rem, every list would be the same size.

Should I use px or rem for spacing?

Either works. Spacing in rem grows when the reader raises the default font size, which keeps text and the space around it in proportion. Borders and hairlines are usually left in px, because a 1px line should stay 1px.

Why does my em value come out different from rem?

Because the parent has its own font size. If a card sets font-size: 20px, then 1em inside it is 20px while 1rem is still 16px. Type 20 in the parent box to see the em values for that card.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.