Skip to content
hateitall

CSS clamp() Generator

Get a fluid value that hits your exact sizes at both viewport edges, with the proof shown beside it.

Processed locallyIn: NumberOut: CSS

Loading tool…

How to use css clamp() generator

  1. Enter the size you want at the smallest and at the largest viewport, in px or rem.

  2. Enter those two viewport widths and your root font size.

  3. Pick the CSS property and selector.

  4. Read the proof table, try any width with the slider, then copy the CSS.

What this tool does

  • Writes clamp(min, intercept rem + slope vw, max), with a rem part so browser zoom still works.
  • Handles values that shrink as the screen grows, keeping the clamp bounds in the right order.
  • Proves the result at half the min width, the min, the middle, the max and beyond, comparing the straight line, the rounded CSS and the size this browser actually computes.
  • Works for any length property: font-size, padding, margin, gap, width or a custom property.

How the result is verified

For each test width the tool lays the generated CSS out in a hidden frame of that width and reads the computed size back, so the table shows the browser's own answer next to the maths.

Frequently asked questions

How is the preferred value calculated?

The slope is (max size minus min size) divided by (max viewport minus min viewport). Multiplied by 100 it becomes the vw part. The rem part is the min size minus slope times the min viewport, divided by the root size.

Why not just use vw for the size?

Pure vw text ignores the reader's font size setting and barely grows with zoom. Adding a rem part keeps it responsive to both.

Is my data uploaded to a server?

No. Everything you drop, paste or type is processed by code running in this browser tab. You can check it yourself: open your browser's developer tools, watch the Network panel, and use the tool. No request carries your data.

Modular type scale with common ratios, fluid option and CSS variables

Number→ CSS custom propertiesLight on device

px, rem and em both ways with any root size, plus bulk CSS rewrite

Number · CSS→ NumberLight on device