Free tool

PX to REM Converter

Convert pixel sizes to rem and em for responsive CSS, or turn rem values back into pixels, using the root font size you choose.

Report a problem or suggest a fix for this tool

What is px to rem converter?

A rem is a CSS unit equal to the font size of the root element, which is usually the html tag. By default browsers set it to 16 pixels, so 1rem is 16px, 1.5rem is 24px and 0.5rem is 8px.

Using rem instead of pixels lets text and spacing scale when a user changes their browser font size, which helps accessibility. This converter does the math so you do not have to divide by 16 every time.

How to use the px to rem converter

  1. Choose pixels to rem or rem to pixels.
  2. Enter the value and, if your site changes it, the base font size.
  3. Copy the result into your CSS. A table of common sizes is shown below.

How the px to rem converter works

Rem equals pixels divided by the base font size, and pixels equal rem times the base font size. With the default base of 16, 24 pixels is 24 divided by 16, which is 1.5rem.

The em unit relates to the font size of the parent element rather than the root. If the parent font size equals your base, the em value matches the rem value, so the tool shows both as the same number for a simple case, and the percent form as well.

Worked example

With a base of 16 pixels, 24px is 1.5rem. A common scale is 12px for 0.75rem, 14px for 0.875rem, 16px for 1rem, 20px for 1.25rem and 32px for 2rem.

Common uses of the px to rem converter

  • Writing responsive typography in CSS.
  • Converting a design file from pixels to a rem scale.
  • Setting spacing that respects user font settings.
  • Building accessible layouts.
  • Checking sizes in a design system.

Tips and common mistakes

Do not change the root font size to 10px for easy math, because it overrides the user preference. Use 100 percent and let the math do the work.

Use rem for font sizes and spacing, and use pixels for thin borders and shadows where scaling is not needed.

Background: what to know before you rely on it

Browsers let people set a larger default font size, which many users with low vision rely on. Pixel based font sizes ignore that setting, while rem based sizes follow it. That is why accessibility guidance recommends relative units for text.

Media queries can also use em or rem so that breakpoints move with the font size. This keeps the layout readable for people who zoom text, instead of switching layout at a fixed pixel width.

Private, free and fast

This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all developer tools, or browse the full list of tools.

Field by field guide

  • Direction: Choose which unit you are starting from.
  • Value: The size to convert. The example value is 24.
  • Base font size (px): The root font size. Browsers use 16 by default. The example value is 16.

Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.

Rem, em and percent

Rem always looks at the root font size, which makes it predictable. Em looks at the parent, so nested elements can compound and grow or shrink unexpectedly.

Percent for font size behaves like em. Use rem when you want a size that does not depend on nesting.

Expert tips

  • Keep the root font size at 100 percent.
  • Use a scale such as 0.75, 1, 1.25, 1.5 and 2rem.
  • Use clamp for fluid type.
  • Test with a larger browser font size.
  • Use pixel values for 1px borders.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the base font size. With the default of 16, 24px divided by 16 is 1.5rem.

What is 16px in rem?

16px is 1rem when the base font size is 16 pixels.

What is the difference between rem and em?

Rem is relative to the root font size. Em is relative to the font size of the parent element.

Should I use rem for everything?

Use it for text and spacing. Fixed details such as hairline borders can stay in pixels.

Related tools

Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional.