Skip to content
SPCXTools

Px to Rem

Convert pixels to rem and vice versa instantly, with a customizable base font size and a handy reference table.

Runs locally — files never leave your device

Loading tool…

How to use Px to Rem

  1. 1Enter a pixel value in the px field to instantly see its rem equivalent.
  2. 2Alternatively, type a rem value in the rem field to convert it back to pixels.
  3. 3Adjust the base font size if your project uses a root size other than the standard 16px.
  4. 4Click the copy button to grab the rem value and a helpful CSS comment snippet for your code.
  5. 5Scroll down to view the quick-reference table for common pixel sizes converted to rem and em.

A fast, local px to rem converter

This two-way px to rem converter makes it easy to translate static pixel measurements into accessible, scalable relative units. Whether you are translating a design mockup into code or refactoring an older stylesheet, you can instantly calculate the exact CSS values you need.

Every calculation happens instantly as you type. Because the tool runs entirely locally in your browser, there is no loading time or network delay. You can seamlessly convert pixels to rem, or switch directions and convert rem to px, all without leaving your keyboard.

Why convert pixels to rem?

For years, web developers used pixels (px) for everything from font sizes to padding. However, pixels are absolute units. If a visually impaired user changes their browser settings to display text at a larger default size (for example, 24px instead of the standard 16px), any text hardcoded in pixels will ignore that preference and remain small.

By using rem (root em) units, your entire layout respects the user's settings. If the user increases their default font size, your rem-based typography, margins, and paddings will scale up proportionately. This makes your website significantly more accessible and responsive. Using a css rem calculator takes the guesswork out of this process, allowing you to write accessible code while still matching the exact pixel dimensions provided by your design team.

How the CSS rem calculator works

The math behind the conversion is simple, but doing it repeatedly in your head can slow down your workflow. The formula to convert pixels to rem is:

Target Pixels ÷ Base Font Size = Rem Value

By default, almost all web browsers use a base font size of 16px. If you want a heading to appear as 32px on a standard screen, you divide 32 by 16, giving you 2rem.

If you are working with an existing codebase and need to understand how large a relative unit will appear, you can use the tool to convert rem to px. The formula simply reverses:

Rem Value × Base Font Size = Pixel Value

This calculator handles both directions simultaneously. Just type into either field, and the other updates instantly. It also rounds complex decimals to four places, keeping your CSS clean and readable without sacrificing precision.

Working with custom base font sizes

While 16px is the web standard, some projects modify the root font size. A very common technique in older codebases is the "62.5% trick." Developers would set html { font-size: 62.5%; } in their CSS. Since 62.5% of the default 16px is exactly 10px, this changes the base font size to 10.

With a base of 10, the math becomes effortless: 24px is 2.4rem, 18px is 1.8rem, and so on. If you are working on a project that uses this technique, or any other custom root size, simply change the Base font size input in the calculator. The tool accepts any base between 1 and 100, and will instantly recalculate your current values and update the entire reference table.

Beyond typography: spacing and layouts

While rem units are most famous for font-size, they are equally important for layout properties. Modern CSS best practices recommend using relative units for:

  • Margin and Padding: Ensuring that the whitespace between elements scales up when the text scales up, preventing cramped layouts.
  • Width and Height: Creating buttons or input fields that grow naturally alongside the text inside them.
  • Media Queries: Defining breakpoints in rem or em ensures that layouts shift based on the actual size of the text, not just the physical width of the screen.

When building complex UI components, you can pair this tool with the Box Shadow Generator to create fully scalable, accessible design systems. Once your stylesheet is complete, you can run it through a CSS Minifier to keep your file sizes small for production.

Using the quick reference table

For standard design systems, you often reuse the same spacing and typography scales. Below the main calculator, you will find a generated reference table of common pixel values (from 10px up to 64px) automatically converted to both rem and em units.

This table updates in real-time if you change the base font size. It serves as a perfect cheat sheet for standard spacing increments (like 16, 24, 32, and 48 pixels), saving you from having to type every single value into the calculator. If you ever need to convert other physical measurements, you can also check out our general Unit Converter.

Frequently asked questions

What is a rem in CSS?
"rem" stands for "root em". It is a relative length unit in CSS that is based on the font size of the root element (usually the tag). If the root font size is 16px, 1rem equals 16px.
Why should I use rem instead of px?
Using rem units improves web accessibility. It allows your layout and typography to scale naturally if a user changes their browser's default font size. Hardcoded pixels ignore these user preferences, potentially making text too small to read.
How is the conversion calculated?
The formula is straightforward. To convert pixels to rem, divide the target pixel value by the base font size. For example, 24px divided by a base of 16px results in 1.5rem.
What is the base font size?
The base font size is the pixel value applied to your document's root element. Most modern web browsers default to 16px, which is why 16 is the standard base for this calculator.
What is the difference between rem and em?
While "rem" is relative to the root element, "em" is relative to the font size of the immediate parent element. The calculator shows both in the reference table because they share the same mathematical conversion against a fixed base, even though they behave differently in nested HTML.
Is my data sent to a server?
No. This px to rem converter runs entirely locally in your browser using JavaScript. No data is sent over the network, ensuring instant calculations and complete privacy.