DevDockTools

CSS Clamp Calculator

Generate CSS clamp() values for fluid, responsive design. Input minimum and maximum values with viewport breakpoints to get a perfectly scaling clamp() function.

CSS clamp(min, preferred, max) creates values that scale fluidly between a minimum and maximum based on viewport width — no media queries needed. The preferred value is a linear vw-based expression that the tool calculates from your min/max breakpoints.

Fluid responsive typography without breakpointsResponsive spacing (padding, margin, gap)Scaling heading font sizes across all viewportsReplacing multiple media query overrides with one line
100% private — all processing runs in your browser. No files are uploaded to any server.

Size Range

Viewport Range

CSS Output
clamp(16rem, 26.6667vw + 10.6667rem, 32rem)

Value at different viewports

ViewportComputed (px)Computed (rem)Preview
320px256.00px16.000remAa
640px341.33px21.333remAa
768px375.47px23.467remAa
1024px443.73px27.733remAa
1280px512.00px32.000remAa
1440px512.00px32.000remAa

Frequently Asked Questions

What is CSS clamp() used for?

CSS clamp() creates fluid values that scale smoothly between a minimum and maximum based on the viewport width — perfect for responsive typography and spacing.

How is the preferred value calculated?

The preferred value is a linear function: calc(slope * 100vw + intercept), where slope = (maxValue - minValue) / (maxViewport - minViewport). The calculator does this math for you.

Should I use px or rem?

Use rem for font sizes — it respects the user's browser font preference setting. Use px for layout spacing where you control the base dimensions.

Can clamp() replace all my media queries?

For typography and many spacing values, yes. For layout changes (column counts, navigation patterns), media queries are still the right tool. Use clamp() for scaling within a layout, not for changing the layout itself.

Related Tools