X Xerobit

PX to REM Converter

Convert between px, rem, em, %, pt, vh, and vw. Configurable root font size. Bulk mode rewrites every NNpx in a pasted CSS block to rem in one paste.

Bulk: convert all px values in CSS

PX to REM conversion table

Reference table at the default base font size of 16px. Use the tool above to generate values for any custom base.

Pixels (px)REM (base 16px)
8px0.5rem
12px0.75rem
14px0.875rem
16px1rem
18px1.125rem
20px1.25rem
24px1.5rem
32px2rem
48px3rem
64px4rem

How to convert px to rem

The formula is straightforward: divide the pixel value by the root font size.

rem = px ÷ base-font-size

Examples (base = 16px):
  24px ÷ 16 = 1.5rem
  14px ÷ 16 = 0.875rem
  32px ÷ 16 = 2rem

The default browser root font size is 16px. Unless you or a framework explicitly changes html { font-size }, this is the base you should use. The tool above defaults to 16px and lets you change it to match your project.

The 62.5% trick — setting html { font-size: 62.5%; } — makes 1rem equal 10px, simplifying mental math (1.6rem = 16px, 2.4rem = 24px). Use the 10 base preset to see this scale. Bear in mind that this can interfere with user-agent stylesheets and third-party component styles, so use it carefully.

Why use rem instead of px?

The fundamental reason is accessibility. When a user changes their browser's default font size (Settings → Appearance → Font size), that change only affects elements sized in relative units like rem. Elements sized in px remain fixed regardless of user preferences.

For users who rely on larger text — including people with low vision, dyslexia, or cognitive differences — a site that ignores their font settings creates a real barrier. Building layouts and typography in rem means your design scales correctly from 12px to 24px base without a single media query.

Beyond accessibility, rem simplifies responsive design. Instead of writing separate @media breakpoints to scale text at different viewport widths, a single root font size adjustment can reflow your entire typographic scale. Many design systems (including Material Design and Tailwind CSS) use rem throughout for this reason.

px is still appropriate for: borders and outlines (1px hairlines), box shadows, fixed icon sizes where you want identical visual output regardless of user zoom, and some media query thresholds tied to physical device widths.

PX vs REM vs EM — which to use?

All three units are valid CSS; the choice depends on what the value should be relative to.

A practical rule: use rem for layout and global typography, em for spacing within a component that has its own font-size, and px only for fixed visual elements where scaling would break the design.

Bulk conversion

Paste a CSS block in the bulk-mode textarea. Every NNpx value (where NN is any number) gets replaced with the rem equivalent. The regex (-?\d*\.?\d+)\s*px\b is intentionally precise to avoid mangling values inside selectors or in 0px hacks. This is useful when migrating a legacy stylesheet from pixel-based values to rem.

FAQ

What is the px to rem formula?

Divide the pixel value by your root font size: rem = px ÷ base. At the default 16px base, 24px becomes 1.5rem. You can set any base in the tool above — common values are 16 (browser default), 10 (62.5% trick), and 18 (larger default).

How many px is 1 rem?

At the browser default, 1rem equals 16px. If you or your framework sets a different root font size (for example, html { font-size: 18px; }), then 1rem equals 18px on that page. Always match the base in the converter to your actual CSS root font size.

What about media query px values?

Bulk mode converts all px values, including those inside @media queries. Some teams keep media queries in px (because they correspond to physical device widths) and only convert layout px to rem. Manually edit the bulk output if that's your preference.

Why does converting 17px give 1.0625rem?

17 ÷ 16 = 1.0625. Tools rounding to 2 decimals would show 1.06rem (which is actually 16.96px). This converter keeps 4 decimal places to avoid accumulated rounding drift across a stylesheet.

Does rem work in all browsers?

Yes. The rem unit has had full cross-browser support since 2013 (IE9+). There are no compatibility concerns for modern development — use it freely.

Related CSS tools

Related articles

Part of Frontend & Design tools.


Written by Mian Ali Khalid. Last updated 2026-05-12.