CSS clamp() Calculator
Generate CSS clamp() values for fluid type, with a live preview.
Runs in your browser. Nothing you open or type here is uploaded.
How to use
- Enter the minimum and maximum sizes in pixels.
- Set the viewport range: the screen widths the size should scale between.
- Copy the generated clamp() expression into your CSS.
- Check the live preview to see how the text scales across the range.
Details
CSS clamp() takes three values: a minimum, a preferred value and a maximum. This calculator builds the preferred value as a straight line between your two size-and-viewport points, written as slope × vw plus an intercept. The size then grows smoothly between the two viewport widths and stops at both ends. One declaration replaces the usual stack of media-query overrides, and the same formula works for any property that should scale with the screen.
- Keep the minimum at 16px or above for body text, so it stays readable on small phones.
- Below the minimum viewport the size stays at the minimum; above the maximum it stays at the maximum.
- The same calculation works for padding, gaps and widths, not just font size.
Common questions
What does clamp() do?
It lets font size scale smoothly between a minimum and maximum as the viewport grows — fluid type with no media queries.
How is the formula built?
From your min/max sizes and viewport range: clamp(min, slope·vw + intercept, max), rounded cleanly.