SanWebCorner · CSS Tools

CSS Clamp Generator for Fluid Typography

Generate a fluid font-size using clamp(), rem bounds and a viewport-based preferred value. Set the endpoint sizes and viewport range, then inspect the calculated font size at a simulated width.

Free · no signupInteractive controlsCopy & download

How to generate fluid font sizes

  1. Enter minimum and maximum font sizes in pixels.
  2. Enter the corresponding viewport widths. The maximum viewport must exceed the minimum by at least 1px.
  3. Set the assumed root font size used to convert lengths into rem.
  4. Select Generate clamp CSS. Adjust Preview viewport to inspect the calculated size, then copy or download the stylesheet.

How the calculation works

The preferred value is a straight line between your two endpoints. The slope is the size difference divided by the viewport-width difference. The intercept is the minimum size minus the slope times the minimum viewport width. The tool converts the intercept and bounds to rem and the slope to vw.

font-size: clamp(1rem, 0.666666666667rem + 1.66666666667vw, 2rem);

With a 16px root, that example grows from 16px at a 320px viewport to 32px at 1280px. Outside that range, clamp holds the value at its lower or upper bound. MDN explains the clamp() function and how its minimum, preferred and maximum values interact.

What the preview means

The preview renders the calculated pixel font size at your simulated viewport width and assumed root size. It does not resize this browser. The actual generated CSS is evaluated by the target page using its real viewport and root size.

If the actual root font size changes, the rem bounds and intercept change. The original pixel endpoints will then shift. Do not treat the preview as a zoom test or an accessibility guarantee; check the real page with text enlargement and browser zoom.

Supported ranges

This version supports increasing or constant font-size scales. Sizes must be 0–512px, viewport widths 1–10,000px, and root size 0.1–256px. Invalid or reversed ranges are rejected. Coefficients use up to 12 significant digits, so small rounding differences can occur.

Frequently asked questions

Can both endpoint font sizes be the same?

Yes. The resulting scale is constant.

Can this generate a decreasing font size?

This version deliberately requires the maximum size to be at least the minimum. Decreasing scales need a different interpretation of the endpoint controls.

Why is my old output gone?

Changing calculation inputs clears it so stale CSS is not mistaken for the current settings. Choose Generate clamp CSS again.

Local processing and downloads

The tool component runs locally in your browser without a conversion API or saved input history. Copy exports the current output; Download saves the current result. Normal website advertising and analytics still run on this page.

More CSS tools