CSS Size Calculator

Convert absolute, font-relative, viewport and container-query units against the context you actually ship. Build fluid clamp() values, inspect existing clamps for accessibility risks, and export the same token model as CSS, Tailwind v4 @theme, Tailwind config, SCSS or DTCG JSON. Everything runs locally in this tab.

{{ liveStatus }}

About CSS Size Calculator

What it does. Converts a length between 29 CSS units — print, font-relative, viewport and container-query — and generates the spacing, radius and layout custom properties a design system needs. Both halves share one context, so the number in the converter and the value in the export cannot disagree.

Why the context is editable. Only px is absolute. rem depends on html { font-size } in an element, but media queries use the initial browser font-size instead. em, ch, ex, cap and lh use the local font metrics; container units use the nearest query container. A converter that hardcodes one context answers a question nobody asked.

Tailwind exports. The v4 @theme output uses --spacing for the base scale and named overrides for off-grid or fluid steps, so regular utilities like p-4 keep working. The config output is for older Tailwind projects and produces a ready theme.extend object. SCSS and DTCG JSON preserve the same token model for other pipelines.

svh, lvh and dvh. On mobile the address bar and toolbars retract while scrolling, so a viewport height is really three heights: lvh with the chrome hidden, svh with it shown, and dvh tracking the live value. Set Retractable browser UI to the height of that chrome and the three units separate; leave it at 0 — the desktop case — and they coincide, which is the truth rather than an approximation.

How clamp() is built. A fluid value is a straight line through two points: your small size at the small viewport, your large size at the large one. The middle term is written as a slope in viewport units plus an intercept in rem rather than a bare vw, because a vw-only value ignores the reader's own font-size setting and stops responding to browser zoom. The Clamp Inspector reads existing values back and flags that risk, unreachable bounds, reversed ranges and missing container context.

Nothing you type leaves this browser tab — the whole calculator is a few hundred lines of arithmetic running locally, with no server component and no analytics on your input.