Skip to content
Free · No install required

CSS Unit Converter — px, rem, em, clamp()

Convert between px, rem, and em with a configurable root, plus build fluid clamp() values for responsive typography.

Unit converter

Edit any field — the others update live. Adjust root and parent font sizes to match your project.

px
px
px
rem
em

Fluid value with clamp()

Linearly interpolates between 14px at 320px viewport and 24px at 1280px viewport.

px
px
px
px
font-size: clamp(0.875rem, 0.6667rem + 1.0417vw, 1.5rem);

Tip: use clamp() for typography, container widths, and section padding to scale fluidly across breakpoints without media queries.

Why this tool exists

Two questions you ask weekly:

  • “What’s 18px in rem at a 16px root?” — 1.125rem
  • “What clamp() produces 14px at 320px viewport and 24px at 1280px?” — you’d reach for a calculator.

This tool answers both in seconds. Configurable root and parent so you can match the actual context of your design system, not just default browser values.

A note on em vs rem

em compounds: a 1.2em font-size inside an element that’s already 1.2em lands at 1.44em of the root. That’s useful when you want components to scale relative to their container — labels next to a larger heading, for instance. But it’s a footgun in deeply nested layouts.

rem always references the root. Predictable, but doesn’t react to local context.

The pragmatic rule: rem for design system tokens (font sizes, spacing scale, container widths). em for component-local relationships (icon next to text in a button — 0.875em keeps it proportionate).

Why clamp() replaced the media-query waltz

Before clamp(), fluid typography meant declaring three sizes at three breakpoints. clamp() collapses that into a single line that interpolates linearly. Every modern browser supports it. Every modern design system uses it.

Use cases

  • Migrating a fixed-px design system to rem-based: drop in pixel values, get the rem equivalents to paste into your tokens.
  • Generating fluid heading sizes: H1 from 32px (mobile) to 64px (desktop) becomes a single clamp().
  • Tuning section padding: section padding that scales with the viewport feels more polished than fixed values that look cramped on small screens.
  • Component spacing tokens: when porting from Figma’s pixel grid to a rem-based code system, this is the conversion you do all day.

How to use

  1. 1

    Configure your root and parent

    Set root font size (typically 16px) and parent font size if you're inside a context with a non-default font size. The conversion fields use these as bases.

  2. 2

    Edit any unit

    Type in pixels, rem, or em — the others update instantly. Click Copy on any field to grab that value.

  3. 3

    Build a fluid clamp()

    Set min and max sizes plus the viewport range you want to scale across. The generator produces a clamp() value you can drop into any property that accepts a length.

DevZap Premium

Use this directly on any page with DevZap

DevZap brings every tool into your browser as a one-click extension. No tab switching, no copy-pasting URLs. Inspect, generate, and export from any page you visit.

FAQ

Frequently asked questions

When should I use rem instead of px?
Use rem for typography, spacing, and component sizing in design systems — when a user changes their browser font-size preference, rem-based UIs scale accessibly. Use px for hairlines, borders, and pixel-level art that should stay fixed.
What's the difference between rem and em?
rem is relative to the root (html) font size. em is relative to the parent element's font size. rem is predictable across the page; em compounds inside nested elements, useful for component-local scaling.
What does clamp() do?
clamp(min, preferred, max) clamps a CSS value between bounds. With a viewport-width-based preferred value, it produces fluid values that scale linearly between two viewport widths — replacing media-query-based responsive typography.
Should I always use clamp() for font-size?
For headings and hero text, almost always — fluid scaling looks better than discrete jumps. For body text, hold a constant value and let users override via browser preferences. Don't fluid-scale below 14–16px or readability suffers.

Ready to make your browser smarter?

Install DevZap free. Upgrade when you're ready.