FIRST CH TOOLS / DESIGN / 43 CSS CLAMP CALCULATOR

CSS clamp() Fluid Typography Calculator

Say "24px at 375px wide, 40px at 1280px" and get the clamp(min, vw formula, max) that draws a straight line between those two points. Instead of stepping the size at breakpoints, the value changes continuously with the window. A width slider shows what it actually looks like, and rem output keeps the size responsive to the reader's browser font size.

Two points make the formula

Minimum viewport width (where growth starts)
Maximum viewport width (where it stops)
Minimum size (at the minimum width)
Maximum size (at the maximum width)
Result
clamp(1.5rem, 1.0856rem + 1.768vw, 2.5rem)
font-size: clamp(1.5rem, 1.0856rem + 1.768vw, 2.5rem);
Value at the preview width
Slope (per 100px of width)
vw coefficient
Intercept (the rem term)
Live preview
Window width 768px → 32px

A heading grows to about this size Aa 0123

The slider computes the value for a hypothetical window width — resizing your real window gives the same numbers.

Value at each width
Viewport widthComputedremState
Checks

    Static px ⇄ rem conversion (what 24px is in rem, plus a size scale) lives in PX ⇄ REM / EM Converter; this page builds the formula that changes with the width. Keeping an element's proportions is in Aspect Ratio Calculator, and text legibility against its background is in Contrast Checker.

    How to Use

    1. Enter the two pointsThe size at the narrow end and the size at the wide end. The defaults are 375px → 24px and 1280px → 40px, and the formula updates as you type.
    2. Check it on the sliderDrag the window width to see the real value and the sample text at that width, including the ranges where it stops at the minimum or the maximum.
    3. Copy it"Copy value" gives the bare clamp(…), "Copy declaration" gives font-size: clamp(…);. The type scale tab exports the whole scale as custom properties.

    About This Tool

    Fluid typography is nothing more than a line through two points. Stepping a heading 24px → 32px → 40px at breakpoints makes the text jump at each one, and the sizes just below a breakpoint always feel cramped. clamp() fills the gap continuously, so every width gets the size you intended. This tool solves the slope and intercept of the line through your two points and rewrites the slope as vw and the intercept as rem (the derivation is on the "How it works" tab).

    rem output is the default for a reason. A preferred value built only from vw ignores the browser's font size setting, which risks failing WCAG 2.2 SC 1.4.4. Keeping the intercept in rem — the "Xrem + Yvw" shape — lifts the whole formula when the reader enlarges text. px output is available, but the checks will warn about it.

    Outside the two widths the value is frozen. Because clamp() brackets the preferred value, anything narrower than the minimum viewport width renders at the minimum size, and anything wider than the maximum renders at the maximum. The table and the bar under the slider show which range is fixed and which is fluid. There is no need to push the minimum below 320px or the maximum beyond 2560px — those ranges are constant anyway.

    The type scale tab repeats the same maths per step. A geometric series from the base size and the ratio is built at the minimum width and again at the maximum width, then each step gets its own clamp(). Using a slightly larger ratio at the wide end makes headings pull further away from body text on big screens. The output is custom properties such as --step-0, ready to paste into :root and use as font-size: var(--step-2).

    This is not the static px ⇄ rem converter. Fixed conversions ("24px is 1.5rem") and scale tables are in PX ⇄ REM / EM Converter; this page produces the interpolation formula. Everything is computed in the browser and nothing is uploaded. Directly callable via URL parameters: /en/clamp/?minvw=375&maxvw=1280&min=24&max=40 or /en/clamp/?min=16&max=20&unit=px&prop=padding

    Other Tools