CSS Clamp Calculator
NEWGenerate fluid typography and spacing with CSS clamp() from min and max sizes and viewport widths.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
Fluid typography scales smoothly between screen sizes.
| Viewport | Size (px) | Size (rem) |
|---|---|---|
| 320px | 16 | 1 |
| 375px | 16.46 | 1.029 |
| 480px | 17.33 | 1.083 |
| 640px | 18.67 | 1.167 |
| 768px | 19.73 | 1.233 |
| 1024px | 21.87 | 1.367 |
| 1280px | 24 | 1.5 |
| 1440px | 24 | 1.5 |
| 1920px | 24 | 1.5 |
Quick Examples
Typical inputs and the results this tool produces.
Overview
CSS clamp(min, preferred, max) returns the preferred value but never lets it go below min or above max. Fluid typography uses it to scale a font size, margin or padding smoothly between two viewport widths with no media queries: font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem).
The middle value is a straight line through two points: the size you want at the smallest viewport and at the largest. This calculator works out the slope as (maxSize − minSize) / (maxViewport − minViewport) and the intercept as minSize − slope × minViewport, then writes the slope in vw and the intercept in px or rem. Rem keeps the intercept tied to the user's font-size setting.
Enter the sizes, viewport widths, unit and property, and the result updates instantly, with a preview slider and a table of sizes from 320px to 1920px. Everything runs in your browser.
Why use this tool?
- Exact slope and intercept maths, no guesswork
- px or rem for both sizes and viewport widths
- Live preview and a table of sizes at common viewports
- Handles negative intercepts and shrinking sizes
- Warnings for WCAG-unfriendly scaling ratios
Features
Exact maths
Slope in vw and intercept in px or rem, rounded to four decimals.
px and rem
Choose the unit for sizes and viewport widths, with a configurable root font size.
Live preview
Drag a viewport slider to see the computed size and sample text.
Size table
Computed px and rem at 320, 375, 480, 640, 768, 1024, 1280, 1440 and 1920px.
Any property
Output for font-size, padding, margin, gap, width, height or line-height.
Sanity checks
Warns about equal sizes, 2.5x+ scaling and swapped min/max.
How to Use
Enter sizes
Type the minimum and maximum size, for example 16 and 24, and choose px or rem.
Enter viewport range
Type the viewport widths where scaling starts and stops, for example 320 and 1280.
Check the result
Read the clamp() value, the slope and intercept, the preview slider and the size table.
Copy the CSS
Press Copy CSS and paste the declaration into your stylesheet.