Code tool

CSS Unit Converter

Convert a CSS length between common units using explicit font and viewport context.

In-browser processingNo account requiredPrivacy details ↗

Context: rem uses the root size, em uses the parent size, and viewport units use the entered viewport dimensions. ch and ex are estimates. Percentages and container/query units are not included because their reference box is context-dependent.

Calculation stays in this browser.

A QUICK WALKTHROUGH

How to use this tool

  1. Enter a finite length.
  2. Choose the source and target CSS units.
  3. Set root, parent, and viewport context when relative units are involved.

Explicit context

Absolute units use the CSS 96 dpi reference. rem uses the entered root font size, em uses the entered parent font size, and viewport units use the entered viewport width and height. ch and ex are practical font-metric estimates.

Context-dependent units

Percentages and container/query units are excluded because their reference box depends on the surrounding stylesheet and layout.

Local calculation

The value is converted in your browser and is not uploaded or stored.

GOOD TO KNOW

Common questions

Which units are supported?

px, rem, em, vw, vh, vmin, vmax, ch, ex, cm, mm, in, pt, pc, and Q.

Are relative units exact?

No. rem, em, and viewport units use the context you enter; ch and ex are practical font-metric estimates.

Why are percentages excluded?

A percentage length needs a property-specific reference size, so one universal conversion would be misleading.