Clamp Calculator

What Is the CSS Clamp Calculator?

Generate fluid CSS clamp() values for responsive typography and spacing. Enter minimum and maximum sizes with viewport breakpoints, and get production-ready clamp() declarations.

Why Use This Tool?

Fluid typography scales smoothly between breakpoints without media queries. The clamp() function sets a minimum, a preferred viewport-based value, and a maximum — but calculating the preferred value formula is non-trivial. This tool does the math for you.

How to Use This CSS Clamp Calculator

  1. Set your minimum value — Enter the smallest size (e.g., 16px for body text). This is the floor — the value won't go below this on any screen.
  2. Set your maximum value — Enter the largest size (e.g., 24px). This is the ceiling — the value caps here on large screens.
  3. Define your viewport range — Set the minimum and maximum viewport widths where the fluid scaling should happen (e.g., 320px to 1200px).
  4. Copy the clamp() function — The tool generates the complete clamp(min, preferred, max) value with the correct vw calculation for the preferred (middle) value.

Worked example: the default 16 → 32 px, checked in Chromium

The defaults (16 px at 320 px wide, 32 px at 1200 px) give clamp(1.0000rem, 0.6364rem + 1.8182vw, 2.0000rem). On October 12, 2026 we applied it in Chromium at five viewport widths, then simulated 200% browser zoom on a 1280 px window (which leaves a 640 px CSS viewport) and a reader whose browser font size is 20 px instead of 16.

SituationComputed sizeWhat you might expect
320 px wide16.0 px16 (min)
375 px (common phone)17.0 px—
768 px (tablet)24.1 pxthe tool's preview shows the same
1200 px and wider32 px32 (max)
1280 px window at 200% zoom21.8 CSS px = 43.6 px on screen64 px (2 × 32): only 1.36× bigger
Browser font size 20 px, 760 px wide26.5 px30 px (25% more than 24): the vw part ignores the setting

Frequently Asked Questions

How do I calculate the preferred value?
The formula is: preferred = minSize + (maxSize - minSize) × (100vw - minViewport) / (maxViewport - minViewport). This tool computes it automatically from your inputs.
Can I use clamp() for spacing, not just font sizes?
Absolutely. clamp() works for any CSS property that accepts length values: padding, margin, gap, width, and more. Fluid spacing paired with fluid typography creates layouts that feel intentional at every viewport width.
What is CSS clamp()?+
CSS clamp() is a function that constrains a value between a minimum and maximum while allowing fluid scaling in between. The syntax is clamp(MIN, PREFERRED, MAX). The browser uses the preferred value as long as it stays within the min and max bounds. It's widely used for responsive typography and spacing without media queries.
How is clamp() different from min() and max()?+
clamp(a, b, c) is equivalent to max(a, min(b, c)). The min() function returns the smallest of its arguments, max() returns the largest, and clamp() combines both by constraining a value to a range. clamp() is most readable for responsive sizing.
Is CSS clamp() supported in all browsers?+
Yes, clamp() has excellent support across all modern browsers — Chrome 79+, Firefox 75+, Safari 13.1+, and Edge 79+. The only concern is very old browsers (pre-2020), where you should provide a fallback value before the clamp() declaration.
What is the formula for fluid typography with clamp?+
The clamp pattern for typography is clamp(min-size, preferred-with-viewport-slope, max-size) where the preferred value is a linear function of viewport width. The math is: slope = (max-size - min-size) / (max-viewport - min-viewport), intercept = min-size - (slope * min-viewport), preferred = intercept + (slope * 100vw). The calculator handles the arithmetic and emits the result in either rem or px units depending on your preference.
Why does my clamp output not match the design at the exact breakpoints?+
clamp interpolates linearly between the min and max, which means at intermediate viewport widths the value differs from what you might design at fixed breakpoints. If a Figma file specifies 16px at 320px viewport and 24px at 1440px viewport, the clamp output passes through both endpoints exactly but everything in between is on a straight line. For step changes at specific breakpoints, use container queries or media queries instead. clamp is for smooth fluid scaling.

📖 Learn More

Related Article The Complete Guide to CSS Units → Related Article How to Use CSS Clamp for Responsive Design →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service