Fluid CSS Clamp Generator
Calculate a CSS clamp() expression from minimum and maximum values at two viewport widths. Works for typography, spacing, widths, and other CSS dimensions. Includes the linear interpolation in viewport-width units and requires no JavaScript at runtime.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
A clamp() line built from two value and viewport pairs
Give a value at a narrow viewport and one at a wide viewport; the tool solves the straight line between them. The output is a bare clamp() expression or, with the property box filled, a complete declaration such as "font-size: clamp(1rem, 0.648rem + 1.502vw, 2rem);" that pastes straight into a stylesheet.
Why you would reach for it instead of a media query
A heading that jumps from 16px to 32px at a breakpoint stays small on a 1100px laptop until the breakpoint hits. Interpolating instead grows the size smoothly with the window, with no JavaScript, no resize listener and no second rule to maintain. Spacing scales the same way: padding-block from 8px to 48px is one line rather than two.
Options that change the arithmetic
The unit selector decides where numbers land: px keeps them, while rem and em divide both bounds and the intercept by the root font size, configurable and defaulting to 16px. The slope always comes out in viewport-width percentage from your px inputs, so switching units moves the bounds without changing the growth rate. Decimal places (0 to 6) set rounding, and the property box takes a custom property such as --gap or a plain name.
Edge cases worth knowing before you paste it
The maximum viewport must exceed a positive minimum and the root font size must be positive, or the tool errors instead of printing nonsense. If the maximum value is below the minimum a note says the value shrinks as the viewport grows and the bounds stay smallest-first.
Calculated in the browser, not on a server
The interpolation is plain arithmetic in the tab; breakpoints, root font size and property name are never posted anywhere.
Questions
What does the generated clamp do?
It keeps the value at or above the minimum, scales linearly with viewport width between the chosen breakpoints, and caps it at the maximum.
Does the rem calculation assume a 16px root size?
The root font size is configurable and defaults to 16px. The generated CSS uses rem bounds and a viewport-width slope calculated against that root size.
Is the formula exact at both viewport bounds?
Yes, modulo the selected decimal precision. The computed preferred value equals the minimum at the minimum viewport and the maximum at the maximum viewport.
Related tools
See categoryCSS Unit Converter
Convert between px, rem, em, pt, pc, in, cm, mm and % for CSS lengths.
Aspect Ratio Calculator
Solve, simplify or look up common aspect ratios and resolutions.
Color Contrast Checker
Check WCAG 2.1 contrast ratios for foreground/background colour pairs.
:nth-child An+B Evaluator
Parse CSS An+B (:nth-child, :nth-of-type) microsyntax, validate it, and list which child indices it matches.