CSS Clamp Generator

Generate a rem/vw CSS clamp expression from two font sizes and viewport widths. Set the root font size explicitly.

How to use

Enter the desired minimum and maximum sizes in pixels, along with the viewport widths where they should be reached. The preferred value interpolates linearly between those points and is bounded by rem minimum and maximum values.

For 16px at 320px and 32px at 1280px with a 16px root, the result is clamp(1rem, 0.666667rem + 1.666667vw, 2rem). Paste it as a CSS value, for example font-size: clamp(...).

Behavior and limits

The root font size is an assumption used for the px-to-rem conversion; the tool does not change your stylesheet. Test browser zoom and long text after applying fluid typography, and avoid disabling user font scaling.

Questions & answers

Can I use equal minimum and maximum sizes?

Yes. That produces a constant size. The maximum viewport must still be greater than the minimum viewport.

Is my input uploaded?

No. Processing runs in your browser. This tool does not send your input to an API or save it in local storage. Text tools accept up to 200,000 characters.

Other Languages

CSS Clamp Generator — Base64.sh

CSS Clamp Generator

Generate a rem/vw CSS clamp expression from two font sizes and viewport widths. Set the root font size explicitly.

Share:

References

How we make sure

We check this tool with the automated test suites linked below. Example checks are shown in their original language.

Verification method
Evaluate the generated clamp formula at both viewport endpoints and check font sizes and unit conversion error.
Comparison reference
Independent endpoint arithmetic, such as 320–1280px mapping to 16–32px font sizes.
Verification scope
These samples and boundaries do not prove correctness for every input.
Test source and cases (select a file to read it)

These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.