CSS Clamp() Generator
Generate a fluid CSS clamp() value from a minimum and maximum size and the viewport range they map to. The tool computes the linear preferred value (a px offset plus a vw term) so a font size scales smoothly between breakpoints.
font-size: clamp(16px, 13.0909px + 0.9091vw, 24px);
How to use this tool
- 1
Enter the minimum size in pixels (the value at and below your small viewport).
- 2
Enter the maximum size in pixels (the value at and above your large viewport).
- 3
Set the min and max viewport widths in pixels that define where scaling starts and stops.
- 4
Read the generated clamp() declaration and click Copy to paste it into your stylesheet.
What is a CSS clamp() value and how does this generator build one?
CSS clamp(MIN, PREFERRED, MAX) returns the PREFERRED value but never lets it drop below MIN or rise above MAX. For fluid typography the trick is the middle argument: it must be a viewport-relative expression that, when evaluated, passes through MIN at your small viewport and MAX at your large one. This tool computes that expression with linear interpolation. It finds the slope between your two size/viewport points, slope = (maxSize - minSize) / (maxVw - minVw), converts it to a vw coefficient by multiplying by 100, and derives the px intercept where the line would cross a zero-width viewport. The output looks like clamp(16px, 11.4286px + 0.7143vw, 24px). Below the min viewport clamp() pins to 16px; above the max it pins to 24px; in between the value rises in a straight line. Because clamp() and vw are resolved by the browser, the size updates continuously as the window resizes, with no media queries. Note this generator emits px and vw units (not rem), assumes a single linear segment, and does not re-order arguments, so you must enter a max that is larger than the min and a max viewport larger than the min viewport for sensible output.
Common use cases
Building fluid headings that grow from 24px on mobile to 48px on desktop without writing media-query breakpoints.
Setting responsive body copy that stays readable between a 320px phone and a 1200px laptop.
Scaling section padding or gap values fluidly so layouts breathe proportionally across screen sizes.
Replacing a stack of font-size overrides at 480px, 768px, and 1024px with one clamp() declaration.
Generating clamp() values for a design system so spacing and type scale consistently from one formula.
Quickly checking the px and vw math for a fluid value you sketched out in a design tool like Figma.
Frequently asked questions
Does clamp() work in all browsers?▼
Why does the output use px and vw instead of rem?▼
What happens outside the viewport range I set?▼
What if I enter a max smaller than the min?▼
Why is there a long decimal in the result?▼
Can I use this for spacing, not just font size?▼
Is my data sent anywhere?▼
Related tools
Color Converter (HEX/RGB/HSL)
Convert colors between HEX, RGB, HSL, OKLCH.
CSS Box Shadow Generator
Build CSS box-shadow visually.
CSS Gradient Generator
Build linear and radial CSS gradients.
Cubic Bezier Generator
Build CSS easing curves visually.
Color Palette Generator
Generate harmonious color palettes from any base color.
CSS Border Radius Generator
Build complex CSS border-radius visually.