CSS Clamp Calculator

Use this free CSS clamp calculator to create a copy-ready responsive clamp() formula from minimum size, maximum size, viewport range, and root font size.

All tools
Smoke mascot building a CSS clamp formula with 32px to 64px, 360px to 1280px, clamp(2rem, calc(1.217391rem + 3.478261vw), 4rem), slope, intercept, and middle-size cards.
CSS Clamp Calculator artwork matches the live workflow: enter min and max sizes, viewport range, and root font size, then copy a clamp() formula with slope, intercept, and middle-size checks. View in the smoke-kawaii gallery
Inputs explained Result checks Example values Runs in your browser
CSS clamp formula
clamp(1.125rem, calc(0.782609rem + 1.521739vw), 2rem)

18px to 32px from 360px-1280px viewport

Slope
1.5217391304vw
Intercept
12.5217391304px
Middle size
25px

Clamp is useful for fluid type and spacing, but still test real text wrapping and tap targets on small screens.

Formula steps

  1. Find how much the size should grow across the viewport range.
  2. Convert that growth into a vw slope and rem intercept.
  3. Wrap the result in CSS clamp(min, preferred, max).

How to use the CSS Clamp Calculator

  1. Enter the minimum and maximum size in pixels.
  2. Enter the viewport range where the size should scale.
  3. Press Generate clamp to create a copy-ready CSS formula.
  4. Test real wrapping and spacing in your page before publishing.

What people use it for

Create fluid heading sizes that grow between mobile and desktop widths.

Generate responsive spacing values without writing several media queries.

Convert a design-system min and max size into copy-ready CSS.

Compare the middle size before placing the formula in a stylesheet.

Quick examples

Responsive heading

32px to 64px from 360px to 1280px, root 16px

clamp(2rem, calc(1.217391rem + 3.478261vw), 4rem)

Body text

16px to 20px from 375px to 1200px, root 16px

clamp(1rem, calc(0.886364rem + 0.484848vw), 1.25rem)

Section padding

24px to 72px from 360px to 1440px, root 16px

clamp(1.5rem, calc(0.5rem + 4.444444vw), 4.5rem)

Need the guide or a nearby tool?

Need a slower walkthrough, a related calculator, or the full library? These links keep you close to the task you started.

Frequently asked questions

Plain-language answers about when to use the tool, what it does with your inputs, what to double-check, and how privacy works.

When should I use the CSS Clamp Calculator?

Use it when your task matches one of these common needs: Create fluid heading sizes that grow between mobile and desktop widths. Generate responsive spacing values without writing several media queries. It works best when you already know the text, code, URL, mode, format, or technical setting the page asks for.

What is the CSS Clamp Calculator doing with my inputs?

In plain language: Slope = (maximum size - minimum size) / (maximum viewport - minimum viewport) * 100. Intercept px = minimum size - slope * minimum viewport / 100. The calculator converts minimum size, intercept, and maximum size to rem with the root font size, then formats clamp(minRem, calc(interceptRem + slopevw), maxRem). The examples on the page are there so you can compare your inputs with a filled-out example before copying the answer.

What do the main CSS Clamp Calculator inputs mean?

Minimum size: The smallest value you want the CSS property to use, usually the mobile size in pixels. Maximum size: The largest value you want the CSS property to use, usually the desktop size in pixels. Minimum viewport: The viewport width where the value should stop shrinking. Maximum viewport: The viewport width where the value should stop growing. Root font size: The px value used to convert px values into rem. The browser default is usually 16px. Middle size: A quick midpoint check so you can see whether the scale feels reasonable before copying the CSS.

How should I read the CSS Clamp Calculator answer?

Read the output next to your original input. If the tool changes format, units, encoding, spacing, or capitalization, compare a small sample before copying the whole result into another app.

What should I double-check before trusting the answer?

Clamp formulas control numeric scaling only. Real layouts still need browser checks for text wrapping, readability, zoom, root font-size changes, tap targets, and container width. Also check the selected mode, input format, encoding, and whether the text includes private keys, passwords, or sensitive data.

What does CSS clamp() do?

CSS clamp() keeps a value between a minimum and a maximum. The middle value can be fluid, so a heading, spacing token, or layout value can grow with the viewport without extra media queries.

Why does the preferred value use rem plus vw?

The vw part creates the viewport-based growth. The rem intercept anchors the line so the formula lands on your chosen minimum size at the minimum viewport and your chosen maximum size at the maximum viewport.

Should I use px, rem, or vw in the final CSS?

This calculator asks for pixel inputs because design specs often use pixels, then returns rem endpoints and a rem-plus-vw preferred value. That keeps the formula friendlier to root font-size changes while still matching your design numbers.

What viewport range should I choose?

Use the width range where you actually want the value to scale. A common pattern is a mobile width such as 360px or 375px and a desktop width such as 1200px, 1280px, or 1440px.

Can I use this for spacing, not only font-size?

Yes. clamp() can work for font-size, margin, padding, gaps, widths, and other numeric CSS values. For spacing, still check small screens so the fluid value does not crowd content.

Why can text still wrap badly after using clamp()?

clamp() only controls the numeric size. Long words, narrow containers, line height, font choice, and content length can still create awkward wrapping, so check the real component in a browser.

Is this the same as container queries?

No. This formula scales with viewport width because it uses vw. Container queries respond to a component container. Use browser testing or container-query CSS when the component width matters more than the full viewport.

Does the site save what I enter?

No. The tool runs in your browser tab. Your recent answers stay only on the page while you use it, and they are not sent to a server.

Related tools