Skip to content

CSS Clamp Generator

New
Developer Tools•Client-Side & Private

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.

Tool workspace

Smallest screen the fluid type scales from — usually a phone.

Widest screen the fluid type scales to — usually a desktop.

Body text size on the smallest screen.

Body text size on the widest screen.

Each heading step multiplies the size below it by this ratio.

Copy plain :root CSS variables, or a Tailwind fontSize config.

Formula: slope = (max size − min size) ÷ (max viewport − min viewport); intercept = min size − slope × min viewport; then clamp(min, intercept + slope × 100vw, max). The browser picks the middle value, so text grows smoothly between your two viewport widths and never goes outside the min/max.

Body text

clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)

16px at 320px → 24px at 1280px

H1 heading

clamp(3.8147rem, 3.1789rem + 3.1789vw, 5.722rem)

61.04px at 320px → 91.55px at 1280px

Live preview — resize your browser to see it scale

Heading 1 — fluid type in action

Heading 2 — scales with the viewport

This body text uses the generated clamp() value, so it grows smoothly from 16px on a 320px screen to 24px on a 1280px screen — no media queries needed.

LevelMin sizeMax sizeclamp() valueCopy
Body16px (1rem)24px (1.5rem)clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)
H620px (1.25rem)30px (1.875rem)clamp(1.25rem, 1.0417rem + 1.0417vw, 1.875rem)
H525px (1.5625rem)37.5px (2.3438rem)clamp(1.5625rem, 1.3021rem + 1.3021vw, 2.3438rem)
H431.25px (1.9531rem)46.88px (2.9297rem)clamp(1.9531rem, 1.6276rem + 1.6276vw, 2.9297rem)
H339.06px (2.4414rem)58.59px (3.6621rem)clamp(2.4414rem, 2.0345rem + 2.0345vw, 3.6621rem)
H248.83px (3.0518rem)73.24px (4.5776rem)clamp(3.0518rem, 2.5431rem + 2.5431vw, 4.5776rem)
H161.04px (3.8147rem)91.55px (5.722rem)clamp(3.8147rem, 3.1789rem + 3.1789vw, 5.722rem)

Your CSS — copy it all

How clamp() works

clamp(min, preferred, max) tells the browser to use the preferred size, but never smaller than min and never larger than max. Here the preferred size is a straight line — intercept + slope × 100vw — that passes through your min size at your min viewport and your max size at your max viewport. Below 320px the text stays at the minimum, above 1280px it stays at the maximum, and in between it scales smoothly with the screen. That is fluid typography with one line of CSS and no media queries. Using rem for the min, max and intercept keeps the sizes relative to the user's browser font-size setting, so people who enlarge text for accessibility still get larger text.

Loading tool controls…

Files processed locally — never uploaded to our servers
Free Instant Private

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

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.

1

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).

2

Pick a Ratio and Units

Choose a modular scale ratio from 1.125 to 1.618, and rem (recommended) or px.

3

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

Setting Up Fluid Type for a New SiteGenerate the :root block once, then use var(--font-size-body) and var(--font-size-h1) across the whole site.
Replacing Media-Query Font SizesSwap a stack of breakpoint font-size rules for one clamp() value per level.
Matching Headings to Body TextKeep H1–H6 in proportion to body text with a single ratio instead of six hand-picked sizes.
Shipping a Tailwind Type ScaleExport the fontSize config and use text-h1 to text-body classes in a Tailwind project.
📐

CSS Clamp Generator - Fluid Type Scale

Formula Equation:
slope = (max size − min size) ÷ (max viewport − min viewport); intercept = min size − slope × min viewport; clamp(min, intercept + slope × 100vw, max)

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

  1. 1Defaults: body 16→24px, viewports 320→1280px, ratio 1.25
  2. 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)
  3. 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

Frequently Asked Questions about CSS Clamp Generator

Frequently asked questions

clamp(min, preferred, max) tells the browser to use the preferred size, but never smaller than the minimum and never larger than the maximum. With a preferred size based on the viewport width, text grows smoothly as the screen gets wider, then stops at your limits. It is fluid typography in one line of CSS, with no media queries.

It is a straight line between your two endpoints: slope equals (max size minus min size) divided by (max viewport minus min viewport), and the intercept equals min size minus slope times min viewport. The preferred value is intercept plus slope times 100vw, so the size equals your min size at your min viewport and your max size at your max viewport.

Use rem. Rem sizes are relative to the user's browser font-size setting, so people who enlarge text for accessibility still get larger text. Px values are absolute and ignore that setting. This generator defaults to rem and converts your px inputs by dividing by 16.

The ratio sets how much bigger each heading is than the level below it: every step multiplies the size by the ratio. With a ratio of 1.25, H6 is 1.25 times body, H5 is 1.25 times H6, and so on up to H1. A larger ratio like 1.5 gives more dramatic headings; a smaller one like 1.125 keeps them closer together.

With the defaults — body 16→24px, viewports 320→1280px, 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). H6 sits between them at clamp(1.25rem, 1.0417rem + 1.0417vw, 1.875rem).

Below the min viewport the text stays at the minimum size, and above the max viewport it stays at the maximum — the preferred size only changes in between. With the defaults, text is 16px on a 320px screen or narrower, 24px on a 1280px screen or wider, and scales smoothly in between.

Complementary utilities for your workflow

View all →
You are here

CSS Clamp Generator

Fluid clamp() font sizes for body and H1–H6, with live preview.

Current tool

CSS Formatter

Beautify CSS with clean rules and indentation.

Try tool

CSS Minifier

Minify and compress CSS for faster page loads.

Try tool
Popular

JSON Formatter

Format, beautify, and syntax-highlight JSON data.

Try tool

JSON Validator

Validate JSON and get precise syntax error locations.

Try tool