Skip to content
TabBench

PX to REM Converter

Convert pixels to rem and em units, and calculate fluid typography CSS clamp() formulas.

Runs in your browser. Nothing you add is uploaded.

What the PX to REM Converter does

Convert between pixels and rem at any root font size, with the em, percentage and point equivalents shown alongside, and generate a CSS clamp() value for fluid type that grows smoothly between two screen widths. The clamp() section includes a viewport slider so you can watch the computed size change, and a reference table lists Tailwind's font-size classes in rem and pixels.

How to convert px to rem and build a clamp() value

  1. Choose the root font size: 16px (the browser default), 14, 12 or 10.
  2. Type a pixel value to get rem, or a rem value to get pixels; the two fields stay in sync.
  3. For fluid type, enter the smallest and largest viewport widths and the font size you want at each.
  4. Drag Simulate Viewport to check the size at widths in between.
  5. Copy the clamp() value into your font-size declaration.

The PX to REM Converter runs entirely in your browser — nothing you enter is uploaded, stored, or logged.

How it works

Pixels to rem

rem = px ÷ root font size

rem is measured against the font size of the html element, 16px unless a stylesheet or the reader's settings change it.

Example: 24px ÷ 16px = 1.5rem. With a 10px root, the same 24px is 2.4rem.

Fluid font size with clamp()

slope     = (max size − min size) ÷ (max width − min width)
intercept = min size − slope × min width
font-size: clamp(min, slope × 100vw + intercept, max)

The preferred value is a straight line through the two size and width points; clamp() stops it at the minimum and maximum. Sizes are divided by the root font size to give rem.

Example: 16px at 375px to 24px at 1280px: slope = 8 ÷ 905 = 0.00884, intercept = 16 − 0.00884 × 375 = 12.685px = 0.7928rem → clamp(1rem, 0.884vw + 0.7928rem, 1.5rem).

When to use it

Turning a design into code

Design tools give sizes in pixels. With the usual 16px root, 14px is 0.875rem, 18px is 1.125rem and 24px is 1.5rem. Sizes in rem grow when a visitor raises their browser's default font size, which pixel sizes ignore.

Fluid headings without breakpoints

For a heading that should be 16px on a 375px phone and 24px on a 1280px laptop, the calculator produces clamp(1rem, 0.884vw + 0.7928rem, 1.5rem): 16px at 375px, about 19.5px on a 768px tablet, and 24px from 1280px up. One declaration replaces a ladder of media queries.

Reading an older stylesheet

Some stylesheets set html { font-size: 62.5% } so that 1rem equals 10px. Switch the root to 10px to read their values correctly, and be aware that the trick shrinks text in any component that assumes the 16px default.

Good to know

  • rem is relative to the root (html) font size; em is relative to the element's own font size, so nested ems compound: 1.2em inside 1.2em is 1.44 times the root.
  • Points are a print unit. In CSS, 1pt = 1/72 inch and 1px = 1/96 inch, so 16px = 12pt.
  • Keep the clamp() middle term as vw plus rem, as generated here. A font size in vw alone ignores the reader's font-size setting, which fails WCAG's resize-text requirement.
  • The minimum and maximum in the clamp() value are in rem too, so the limits also follow the reader's font-size preference.

Frequently asked questions

Why should web developers use REM instead of PX?

REM units scale relative to the root font size set by the user's browser. Using REM ensures your site respects accessibility settings for visually impaired users who increase default font sizes.

How does the CSS clamp() formula work?

The clamp(min, val, max) function sets a value between an allowable minimum and maximum. In fluid typography, 'val' uses a linear slope equation with viewport units (vw) to scale smoothly as the browser window resizes.

What is the difference between REM and EM?

REM (root em) is always relative to the font size of the <html> element. EM is relative to the font size of the element it is used on (or its parent, for font-size itself), so values compound when elements are nested.

How is the clamp() value calculated?

The preferred size is a straight line through your two points: slope = (max size − min size) ÷ (max width − min width), and intercept = min size − slope × min width. The middle term is slope × 100 in vw plus the intercept in rem, and clamp() holds it between your minimum and maximum sizes.

Page last updated . Found a wrong result or a mistake on this page? Let us know.