CSS clamp generator

Enter font-size endpoints and viewport widths, then choose px or rem output. Copy the CSS value from the results.

Inputs
px
Your assumed root size; not a browser guarantee.

Results

CSS font-size value
clamp(1rem, 0.666666666667rem + 1.66666666667vw, 2rem)
Slope × 100 (vw coefficient)
1.66666667
Intercept
10.66666667 px
Maximum / minimum
2×
Sizes at sample viewport widths (assumed root size)
Viewport (px)Font size (px)Font size (rem)
320161
37516.91671.0573
76823.46671.4667
102427.73331.7333
1280322
1440322
1920322
  • Test text resizing to 200% and check for lost content or functionality. A generated clamp does not establish WCAG conformance.

Results update as you type. The share link stores your inputs after the # in the address, which is not sent to our server, but anyone you send it to can read them.

How it works

Convert rem inputs to px using your root-size assumption. A straight line through the two endpoints gives the slope and intercept below. CSS Values 4 defines vw as one percent of viewport width, rem relative to the root font, and clamp() as a preferred value constrained by bounds.

slope = (max size − min size) / (max width − min width) intercept = min size − slope × min width preferred = intercept + (100 × slope)vw

For rem output, divide the bounds and intercept by the assumed root size. Calculations keep full precision; CSS coefficients use 12 significant digits and the sample table uses four decimal places. Root changes can shift the resulting endpoints.

WCAG 1.4.4 requires text to resize to 200% without losing content or functionality. The warning above a 2.5 maximum/minimum ratio is a tool heuristic, not a WCAG rule or conformance test. Test zoom and text resizing on the finished page.

Worked examples

16px to 32px across 320–1280px

With a 16px root, slope = 1/60 and intercept = 10.666667px. Output: clamp(1rem, 0.666666666667rem + 1.66666666667vw, 2rem). At 800px, size is 24px.

A simple rem range

For 1rem to 1.5rem across 20rem to 70rem, with a 16px root, output is clamp(1rem, 0.8rem + 1vw, 1.5rem). At 720px, size is 20px.

Frequently asked questions

Can I use px and rem inputs together?
Yes. Font sizes and viewport widths each have their own unit selector. All rem conversions use the root size you enter.
What happens outside the viewport range?
The font size stays at the minimum below the lower width and at the maximum above the upper width.
Can the endpoints be equal?
Font sizes may be equal, producing a constant value. Viewport widths must be distinct and increase.
Does rem output guarantee accessible zoom?
No. The viewport term can counteract zoom. Check actual text enlargement and layout with browser zoom and user font settings.

Sources

Last reviewed 2026-11-14. The method is written out above so you can check our math.