CSS clamp() Generator
Turn a minimum and maximum font size plus a minimum and maximum viewport width into a single breakpoint-free CSS clamp() fluid-typography expression.
CSS clamp() Generator — Type your smallest and largest font sizes and the viewport range they should scale across, and a ready-to-paste clamp() value is built for you using the proven Utopia linear-interpolation math. The result scales smoothly between your bounds with no media queries at all. Everything is computed in your browser with plain JavaScript — nothing is uploaded to a server, so your values stay private.
What is CSS clamp() Generator?
The CSS clamp() Generator is a free fluid-typography calculator for front-end developers and designers. You give it a minimum font size, a maximum font size, a minimum viewport width and a maximum viewport width; it returns a clamp(min, preferred, max) declaration where the preferred value mixes a rem offset with a vw slope, so text grows linearly with the screen and never escapes your bounds. This removes the need for stacked font-size media queries and keeps headings and body copy responsive on every device. Pick a preview size to see how the value renders, switch the output unit between rem and px, and copy the line straight into your stylesheet.
How to use CSS clamp() Generator
- Enter the minimum font size — the size the text should be on the smallest screen.
- Enter the maximum font size — the size the text should reach on the largest screen.
- Set the minimum and maximum viewport widths that the size should scale between.
- Open settings to switch the output unit (rem keeps things accessible; px is also available) if you prefer.
- Choose a preview size to render sample text at that viewport, then read the live clamp() value.
- Copy the generated clamp() expression and paste it into your CSS font-size.
Examples
Body text 16px to 20px
Input
min font 16, max font 20, min vw 320, max vw 1240
Output
font-size: clamp(1rem, 0.913rem + 0.435vw, 1.25rem);
Hero heading 32px to 64px
Input
min font 32, max font 64, min vw 320, max vw 1536
Output
font-size: clamp(2rem, 1.474rem + 2.632vw, 4rem);
Small label, fixed range
Input
min font 12, max font 14, min vw 480, max vw 1280
Output
font-size: clamp(0.75rem, 0.675rem + 0.25vw, 0.875rem);
Frequently asked questions
- How does the clamp() value scale without media queries?
- clamp(min, preferred, max) takes a lower bound, a preferred (fluid) value and an upper bound. The preferred value is a line of the form rem + vw, computed so the font equals your minimum at the minimum viewport and your maximum at the maximum viewport. Between those widths the browser interpolates automatically, and outside them clamp() pins the size to the nearest bound — all in one declaration.
- Why is the output in rem instead of px?
- Using rem for the fixed parts respects the user's browser font-size setting, which is better for accessibility. The viewport-relative slope is expressed in vw. You can switch the unit to px in settings if your project needs absolute units, but rem is the recommended default.
- What viewport range should I use?
- A common choice is your smallest supported width (often 320px or 360px) for the minimum and your widest content container (such as 1240px–1536px) for the maximum. The font is fully fluid only inside that range; below it the text stays at the minimum and above it at the maximum.
- Does this work for any CSS length, not just font-size?
- Yes. The generated clamp() value is just a length, so you can paste it into padding, margin, gap, or any property that accepts a length. The labels mention font-size because fluid typography is the most common use, but the math is identical for spacing.
- Is my data sent anywhere?
- No. The calculation runs entirely in your browser with JavaScript — your font sizes and viewport widths are never uploaded to any server, so the tool works privately and even offline once the page has loaded.
Related tools
Code to Image
Turn a code snippet into a polished, syntax-highlighted PNG card in your browser, with a theme, gradient or transparent background, and padding — no upload.
Color Contrast Checker
Check the WCAG contrast ratio between a foreground and background HEX color and see whether it passes AA and AAA for both normal and large text.
Color Mixer
Blend two HEX colors at a chosen ratio in RGB or Lab color space and read the resulting mid color back as a swatch and copyable HEX value.
Color Shades Generator
Turn one base HEX color into a Tailwind-style 50-950 shade scale, mixing toward white and black, each step with a swatch and copyable HEX.