CSS Clamp Calculator

Turn a min and max size plus two viewport widths into a fluid CSS clamp() value, computed live in your browser.

The CSS Clamp Calculator runs entirely in your browser. The viewport widths, sizes, and root font size you enter never leave your device and nothing is uploaded to ArrayKit.

Open the CSS Unit Converter

About CSS Clamp Calculator

The CSS Clamp Calculator turns four numbers — a min and max size in pixels plus the two viewport widths they map to — into a ready-to-paste clamp() value for fluid typography and spacing. It fits a straight line between your two anchor points, works out the vw slope and the rem intercept, and pins the result to your min below the small viewport and your max above the large one. A live preview slider shows the exact rendered size at any width in between, so you can eyeball the ramp before shipping it. Copy the raw clamp() value, a font-size declaration, or a Tailwind arbitrary value. Everything is computed on your device — the sizes you type stay in the browser and nothing is uploaded to ArrayKit.

Features

How to use the CSS Clamp Calculator

  1. Enter your min and max viewport widths in pixels
  2. Enter the min and max sizes the element should reach at those widths
  3. Adjust the root font size if it is not the default 16px
  4. Drag the preview slider to check the rendered size across the range
  5. Copy the clamp() value or the CSS declaration into your stylesheet

Example

Input

min viewport 320px, max viewport 1200px
min size 16px, max size 24px, root 16px

Output

font-size: clamp(1rem, 0.8182rem + 0.9091vw, 1.5rem);

16px at 320px grows to 24px at 1200px and holds flat outside that band.

Common errors & troubleshooting

Frequently asked questions

How does a CSS clamp calculator compute the vw slope?
It draws a line through your two anchor points: slope = (maxSize − minSize) / (maxViewport − minViewport). Because 100vw equals the viewport width, the vw coefficient in the value is that slope multiplied by 100, and the rem intercept is what is left when the line is extended back to a zero-width viewport.
Why does the middle term mix rem and vw?
The preferred value is a straight line: a fixed part that does not depend on width (the rem intercept) plus a part that grows with the viewport (the vw slope). Mixing the two lets the size scale smoothly between your min and max instead of jumping at a breakpoint.
Should I use px or rem in the clamp bounds?
rem bounds respect the user's browser font-size setting, which is better for accessibility, so this tool outputs rem by default. You can switch the readout to px, but rem clamp bounds are the safer choice for text sizing.
Can I use the same clamp() value for margins and gaps?
Yes. clamp() works for any length, so the value applies to padding, margin, gap, and grid tracks as well as font-size. Use the fluid spacing preset as a starting point and adjust the min and max sizes.
What root font size should I enter?
Use whatever your page sets on the html element — 16px is the browser default and the tool's default. If you scale the root elsewhere, enter that value so the rem output maps to the pixels you actually see.
Are the sizes I type uploaded anywhere?
No. The CSS Clamp Calculator runs entirely in your browser. The viewport widths and sizes you enter are used only to compute the value on your device and are never sent to ArrayKit.

Related tools

All ArrayKit tools