Free online tools

CSS Clamp Generator

Set a size for a narrow viewport and another for a wide viewport. Get a CSS clamp() that interpolates between them, with sample sizes at the edges and midpoint.

Enter your values

Used to calculate the rem terms. The preview uses the target sizes in CSS pixels.

This tool processes your input in your browser.

Result

Define the two viewport widths

For example, set 20 px at 360 px wide and 40 px at 1,440 px. The middle term in clamp() changes linearly between the two sizes. Outside that range, the minimum and maximum restrict the result.

Set the root font size used in your project

The result combines rem and vw. At the root size you entered, the generated expression reaches the chosen sizes at the two target widths. A different root size changes where the expression reaches its limits, so test with browser zoom and user font settings.

Frequently asked questions

Can the value decrease on a larger screen?

Yes. Enter a smaller size for the wide viewport. The preferred CSS value then uses a negative vw term, and the minimum and maximum are ordered by size.

Can I use the expression for spacing?

Yes. Use the generated clamp() value in a property that accepts CSS lengths, such as gap or padding, after choosing appropriate limits.