CSS clamp() Generator

Turn min/max sizes and a viewport range into a responsive clamp() value.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

A CSS clamp() generator that converts a minimum size, a maximum size, and a viewport range into a single responsive clamp() value you can paste straight into your stylesheet. It is built for front-end developers and designers who want fluid typography or fluid spacing that scales smoothly between a phone and a wide desktop without writing a stack of media queries. You can define a whole type scale or spacing scale at once, watch every step respond as you drag a simulated viewport slider, and export the result as ready-to-use CSS custom properties.

How it works

Each row describes one fluid value with two anchor points: the size you want at your smallest viewport and the size you want at your largest viewport. The generator draws a straight line between those two points and expresses it as a vw slope plus a rem intercept — the preferred term inside clamp(). The minimum and maximum become the outer bounds, so the value scales linearly in the middle and then locks at each end. Because the output mixes rem with vw, it respects the user’s browser zoom and root font size, which a pure vw value would ignore. You set the root font size (usually 16px), the min and max viewport widths, and whether you type values in rem or px; switching units re-converts your existing rows automatically so nothing is lost.

Example

Say you want body text at 1rem on a 320px phone growing to 1.125rem on a 1280px desktop. The tool returns something like clamp(1rem, 0.85rem + 0.42vw, 1.125rem). Below 320px the text stays at 1rem, above 1280px it stays at 1.125rem, and in between it scales perfectly straight. Drag the preview slider and you will see the resolved pixel size update live for every row at once — a quick way to sanity-check a full scale before shipping it.

Min sizeMax sizeViewport rangeExample output
1rem1.125rem320 to 1280pxclamp(1rem, 0.85rem + 0.42vw, 1.125rem)
1.25rem1.6rem320 to 1280pxclamp(1.25rem, 1.1rem + 1.1vw, 1.6rem)
1.95rem3.16rem320 to 1280pxclamp(1.95rem, 1.55rem + 3.8vw, 3.16rem)

Everything is calculated in your browser — no values are uploaded or stored on a server, and your scale is remembered locally for next time.

Ad placeholder (rectangle)