Unit Converter
CSS Clamp Generator
Generate a copyable clamp() expression from two viewport widths and desired sizes, using px or rem with a fluid vw term.
CSS Clamp Generator examples
Here the CSS Clamp Generator is applied to growing and shrinking sizes in px and rem.
| Input | Expected result |
|---|---|
| 320→1280 px viewport; 16→40 px size; px output | clamp(16px, calc(8px + 2.5vw), 40px) |
| Same endpoints; rem output at a 16 px root | clamp(1rem, calc(0.5rem + 2.5vw), 2.5rem) |
| 320→1280 px viewport; 40→16 px size; 16 px root | clamp(1rem, calc(3rem - 2.5vw), 2.5rem) |
Supported units & limits
Viewport widths must be 1–100,000 CSS px and at least 1 px apart. Endpoint sizes must be 0–10,000 CSS px. Sizes are entered in pixels for both output modes; rem output needs a root font size of 1–1,000 CSS px. Decimal and scientific notation are accepted. Coefficients are rounded to 15 significant digits, so endpoint matches can be approximate. The tool fits one linear segment and does not choose breakpoints, measure text or validate a complete stylesheet. Numeric overflow and underflow are rejected.
Common mistakes
Keep viewport widths in ascending order even when sizes decrease. The clamp bounds are numeric minimum and maximum sizes, not necessarily start and end sizes. In rem mode, changing the root font after generation changes bounds and the fixed term; the original viewport intersections may move. Test user font settings and zoom separately rather than assuming this expression guarantees readable typography. Users who zoom or change their font size will see rem output scale, while px output from the CSS Clamp Generator will not.
Privacy
Conversions run in your browser. This site does not upload or store the values you enter. We use Google Analytics, loaded through Google Tag Manager, to count page visits and see which tools are used; Google may set cookies for this. The hosting server may keep standard access logs when you load a page.
Conversion guide
Fit two size targets and check the whole range
Enter the smaller viewport width with its desired size, then the larger viewport width with its desired size. Choose px output for fixed CSS pixel bounds or rem output for root-relative bounds. Copy the expression into the target property, then check both endpoints, an intermediate width, user font settings and zoom. For a decreasing scale, keep widths in the same order and reverse the size trend. Paste the expression from the CSS Clamp Generator into font-size, gap or padding; the same formula works for any length property.
CSS Clamp Generator FAQ
Can the size shrink as the viewport grows?
Yes. Keep the start width smaller than the end width and enter a larger start size. The generator uses a negative vw coefficient and sorts the clamp bounds by numeric size.
Why does rem output still contain vw?
The rem term supplies a fixed reference length and vw supplies viewport scaling. The bounds stop the value outside the chosen size range.
What does the copy button copy?
Only the generated CSS expression. Paste it as a length value, for example after font-size: or gap: in a stylesheet.
Will rem output keep the same endpoints after a root font change?
Not generally. The bounds and intercept scale with the root font while the vw term follows the viewport. Recalculate if you need to compare a new root context.