CSS Clamp Generator
Generate fluid clamp() font sizes for body and H1–H6 from your min/max viewport and font sizes, with a modular scale, live preview and copyable CSS.
Loading tool controls…
Verify it yourself: press F12, open the Network tab, and use this tool — your files are never uploaded.
CSS Clamp Generator at a glance
- Price
- Free
- Account
- Not required
- File uploads
- None — your files are never uploaded
- Category
- Developer Tools
Who uses Developer Tools?
Developers and engineers formatting JSON, testing regex, hashing data, encoding values or building API requests.
How to Use CSS Clamp Generator
Follow these simple steps to get instant results in your browser.
Set the Endpoints
Enter your min and max viewport widths (defaults 320px and 1280px) and your min and max body sizes (defaults 16px and 24px).
Pick a Ratio and Units
Choose a modular scale ratio from 1.125 to 1.618, and rem (recommended) or px.
Copy the Export
Copy the :root CSS variables or the Tailwind config, or download fluid-type.css — and check the live preview first.
What is CSS Clamp Generator & How Does It Work?
CSS Clamp Generator builds fluid type scales with clamp(): give it a min and max viewport width and a min and max font size, and it works out the clamp() value for body text and every heading from H6 to H1, following the modular scale ratio you pick. The result is one line of CSS per level — no media queries.
The values are a straight line between your two endpoints: slope is (max size − min size) ÷ (max viewport − min viewport), the intercept is min size − slope × min viewport, and the preferred size is intercept + slope × 100vw. With the defaults (16→24px body, 320→1280px viewports, ratio 1.25) body text is clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem) and H1 is clamp(3.8147rem, 3.1789rem + 3.1789vw, 5.722rem). Below the min viewport the text stays at the minimum; above the max it stays at the maximum.
You get seven levels — Body, H6, H5, H4, H3, H2, H1 — as :root CSS variables (--font-size-body through --font-size-h1), or as a Tailwind fontSize config with lineHeight 1.2 and classes like text-h1. Sizes are rem by default (px divided by 16), so they stay relative to the reader's browser font-size setting, and a live preview shows the scale on the page as you change the inputs.
Key Features & Capabilities
Seven Fluid Levels
Body plus H6 to H1, each with its own clamp() value from one ratio.
Seven Scale Ratios
Minor Second 1.125 to Golden Ratio 1.618 — pick how dramatic the headings are.
rem or px Output
Rem by default, so sizes follow the reader's browser font-size setting.
CSS and Tailwind Exports
:root variables or a Tailwind fontSize config, copyable or downloadable.
Live Preview
Headings and body text rendered with your clamp() values — resize the browser to see them scale.
Pro Tips
- •Bookmark this tool for instant one-click access anytime.
- •Drag and drop files directly onto the input surface for fastest handling.
- •All processing happens in your browser session for maximum speed and data safety.
🎯 Common Use Cases
CSS Clamp Generator - Fluid Type Scale
The preferred size is a straight line through the two endpoints: it equals the min size at the min viewport and the max size at the max viewport. Each heading step multiplies the size below it by the modular scale ratio. Rem values are px ÷ 16.
Worked Example
- 1Defaults: body 16→24px, viewports 320→1280px, ratio 1.25
- 2Body: slope = (24 − 16) ÷ (1280 − 320) = 0.008333; intercept = 16 − 0.008333 × 320 = 13.3333 → clamp(16px, 13.3333px + 0.8333vw, 24px) = clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)
- 3H1 (step 6): 16 × 1.25^6 = 61.04px min, 24 × 1.25^6 = 91.55px max → clamp(61.04px, 50.8626px + 3.1789vw, 91.55px)
Sources & Further Reading
- clamp() — MDN Web Docs
- Using CSS custom properties — MDN Web Docs
Frequently Asked Questions about CSS Clamp Generator
Frequently asked questions
More Developer Tools
Complementary utilities for your workflow
CSS Clamp Generator
Fluid clamp() font sizes for body and H1–H6, with live preview.