DevTools Logo

Px to Rem

PX to REM Converter

Convert pixels ↔ REM with a custom root size, bulk CSS lines, and copy-ready snippets.

Default is usually 16px (1rem). Tailwind and most browsers use this.

Examples

Convert 32px with the default base

Input
Base: 16px
Pixels: 32px
Output
Base: 16px
Pixels: 32.00 px
REM: 2.0000 rem

The default 16px base makes 32px equal to 2rem.

Convert a fractional pixel value

Input
Base: 16px
Pixels: 8.5px
Output
Base: 16px
Pixels: 8.50 px
REM: 0.5313 rem

The converter keeps the fractional input and formats the calculated REM result to four decimal places.

Use a 10px base for a compact scale

Input
Base: 10px
Pixels: 24px
Output
Base: 10px
Pixels: 24.00 px
REM: 2.4000 rem

Changing the base changes the relationship: 24px is 2.4rem when the base is 10px.

About this tool

Type a pixel value and read the rem equivalent, or type rem and read pixels — both fields stay in sync. Conversions use the root font size you set, 16px by default, and the formula is simply rem = px ÷ root size, so 24px is 1.5rem on a 16px base.

The bulk tab converts a whole list at once: paste bare values like 16px, or full declarations such as font-size: 18px and padding: 1.5rem, one per line, and each line comes back converted. A ready-made CSS snippet pairs the result with a comment stating the base size, and the quick-reference grid recalculates common sizes for your chosen root.

Rem matters because it scales with the reader's browser font settings: raise the default font size and everything sized in rem grows with it, which is why style guides and accessibility checkers push rem over fixed pixels. Keep it distinct from em, which is relative to the element's own font size and compounds in nested contexts. Tailwind's spacing scale is rem-based too — its default 4px step equals 0.25rem on a 16px root.

How to use this tool

  1. Set the root size

    Enter your project's base font size in pixels; 16 is the browser default.

  2. Convert a value

    Type into either the pixels or the rem field and read the other.

  3. Convert in bulk

    Paste px values or CSS declarations, one per line, into the bulk tab.

  4. Copy the result

    Use a copy button to grab the value or the generated CSS snippet.

Use cases

Translating a design handoff

Convert measurements from a pixel-based design file into REM values before adding them to a typography or spacing token file.

Building a responsive type scale

Compare the same pixel sizes against different base font sizes to see how a root-relative scale changes across projects.

Checking an existing CSS declaration

Paste the base and pixel value from a stylesheet to confirm the equivalent REM value without doing the division manually.

Creating accessible component dimensions

Use REM for text, spacing and layout values that should respond to the document's root font-size rather than remain fixed in pixels.

Common mistakes

Mistake:Using the viewport width or a browser zoom percentage as the base size.

Fix:The base size is the root font-size used by the CSS rem unit, commonly 16px. Set it to the actual root value for the stylesheet you are editing.

Mistake:Entering zero or a negative base and expecting a conversion.

Fix:The component only updates the base when the value is greater than zero. Restore a positive base size before converting.

Mistake:Treating the displayed decimals as the internal calculation limit.

Fix:Pixels are displayed to two decimals and REM to four, so use the underlying input values when you need more precision than the visible formatting shows.

Mistake:Typing a non-numeric value and assuming the previous result remains visible.

Fix:The component treats an unparsable pixel or REM value as invalid and sets both values to zero; enter a numeric value to resume the conversion.

Frequently asked questions

How many pixels is 1rem?

It equals the root font size of the page — 16px in a default browser setup. If the stylesheet sets html { font-size: 16px }, then 1rem is 16px, 0.5rem is 8px and 2rem is 32px.

What is the difference between rem and em?

rem is relative only to the root font size, so its value is predictable anywhere on the page. em is relative to the current element's font size, so the same em value produces different sizes in nested elements.

Why use rem instead of px?

Pixels ignore the visitor's browser font-size preference, while rem-based layouts grow and shrink with it. That keeps text accessible for low-vision users and lets one stylesheet scale cleanly across devices.

How do I change the base font size?

Set it in CSS with html { font-size: 10px } or a percentage such as 62.5%, then enter the same number in this tool's base-size field so the conversions match your stylesheet.

References & standards