All tools Developer

CSS clamp() Calculator

Generate CSS clamp() values for fluid type, with a live preview.

The quick brown fox jumps over the lazy dog

Runs in your browser. Nothing you open or type here is uploaded.

How to use

  1. Enter the minimum and maximum sizes in pixels.
  2. Set the viewport range: the screen widths the size should scale between.
  3. Copy the generated clamp() expression into your CSS.
  4. 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.