Toolnova
Developer Tools

CSS clamp() Calculator

Generate a fluid CSS clamp() value that scales font size or spacing smoothly between two viewport widths — no media queries required.

  • 100% free
  • No signup
  • Private — in your browser
  • No watermark
Live tool · runs in your browser
Highlights

Why use CSS clamp() Calculator?

  • Generates the exact clamp() formula used by modern fluid-typography systems
  • Supports both px and rem input units (1rem = 16px)
  • Shows a live side-by-side preview at your min and max viewport widths
  • One-click copy of the final CSS declaration — no build tools or plugins needed
Overview

About CSS clamp() Calculator

The CSS clamp() function takes a minimum, a preferred, and a maximum value, and lets the browser pick whichever fits — clamp(min, preferred, max). For fluid typography, the "preferred" value is a linear formula combining rem units and viewport width (vw) so text grows and shrinks smoothly as the browser is resized, instead of jumping at fixed breakpoints.

This calculator does the math for you: give it a minimum size, a maximum size, and the viewport range you want them to apply across, and it works out the exact slope and intercept needed to interpolate between them. The result is a single copy-paste-ready clamp() declaration that behaves identically to hand-written fluid typography, without you needing to calculate the linear equation yourself.

Step by step

How to use CSS clamp() Calculator

  1. 1

    Set your size range

    Enter the smallest and largest font size (or spacing value) you want the element to use.

  2. 2

    Set your viewport range

    Enter the min and max viewport widths across which the size should scale, e.g. 320px to 1280px.

  3. 3

    Copy the clamp() value

    Copy the generated CSS declaration and paste it straight into your stylesheet.

FAQ

Frequently asked questions

What does clamp() actually do?

clamp(min, preferred, max) tells the browser to use the preferred value, but never go below min or above max. For fluid typography, the preferred value is a formula in rem and vw units so it scales continuously with viewport width.

Why does the formula use rem and vw together?

rem keeps the value tied to the root font size (respecting user accessibility zoom settings), while vw makes it responsive to viewport width. Combining them (e.g. 1rem + 2vw) creates a value that scales smoothly and predictably.

Do I need a browser prefix or fallback?

No. clamp() is supported in all modern browsers (Chrome, Firefox, Safari, Edge) with no vendor prefix needed.

Can I use this for spacing, not just font size?

Yes. The same formula works for any length-based CSS property — padding, margin, gap, border-radius and more. Just paste the clamp() value into whichever property you need.

What if my viewport values are the wrong way round?

The min viewport width must be smaller than the max viewport width, and the min size should not exceed the max size — the tool will show a validation message if either check fails.

Is this tool free and private?

Yes. All calculations run locally in your browser with no signup and no data sent anywhere.

Related developer tools

See all developer tools

Browse more free tools

Explore every category in our toolbox.