Fluid Typography & Clamp Calculator
Generate responsive clamp() values for font sizes, spacing, or any CSS property. Set your min/max values and viewport breakpoints — the math is done instantly.
| Step | Name / Role | Min (px) | Max (px) | clamp() value |
|---|
Generate responsive clamp() values for font sizes, spacing, or any CSS property. Set your min/max values and viewport breakpoints — the math is done instantly.
| Step | Name / Role | Min (px) | Max (px) | clamp() value |
|---|
Fluid typography scales smoothly between a minimum and maximum size as the viewport changes. A single clamp() declaration replaces multiple breakpoint-based overrides and produces perfectly proportional text at every viewport width in between.
The CSS function clamp(min, preferred, max) picks the middle value when it falls in range, clamping to the extremes otherwise. The preferred value is a vw-based linear expression calculated from your exact breakpoints.
Slope and intercept are computed from your exact breakpoints — no guesswork or trial and error.
Input in px or rem. Output in px or rem. All conversions use your configured root font size.
Generate a complete modular scale (xs through h1) using classic ratios with one click.
Drag the viewport slider and watch your text resize in real time as it will in the browser.
Given a min font size at a min viewport and a max font size at a max viewport, the tool interpolates linearly. The slope is (maxSize − minSize) / (maxVp − minVp). The intercept is minSize − slope × minVp. The preferred clamp expression becomes slope × 100vw + intercept.
For example, scaling from 16px at 320px to 24px at 1280px: slope = 8/960 ≈ 0.00833, intercept ≈ 13.33px. Result: clamp(1rem, 0.833vw + 13.33px, 1.5rem).
clamp() handles continuous fluid scaling — font sizes, padding, gap, container widths. Media queries handle discrete layout shifts — column changes, component swaps, feature toggles. The two complement each other: use clamp() for smooth property scaling within a layout phase, and media queries to switch between layout phases.
A modular scale uses a fixed ratio between every step. Minor Third (1.2) is compact and readable for dense UIs. Perfect Fourth (1.333) creates clear hierarchy for editorial layouts. Golden Ratio (1.618) produces dramatic jumps — striking for hero sections but demanding careful use in dense content.
The intercept (the fixed px part of the preferred expression) can be negative when the slope is steep relative to the starting viewport. This is mathematically correct — the vw term compensates at every viewport width. The clamping ensures the result never leaves your specified min/max range.
Using rem for min and max respects user browser font preferences (an accessibility best practice). Mixing rem and vw in the preferred value is valid CSS. Choose rem output unless you have a specific reason to use px.
Absolutely. clamp() works for any CSS length property — padding, margin, gap, width, border-radius, and more. Just enter the desired min/max values; the math is identical.
A sequence of sizes where each step multiplies the previous by a fixed ratio. Starting from a base (e.g. 16px) and a Minor Third ratio (1.2): 16 → 19.2 → 23.04 → 27.65... The ratio name comes from music: a Perfect Fourth means 4/3 times the previous step.
Assign each clamp value to a token: --type-base: clamp(1rem, 0.833vw + 13.33px, 1.5rem); defined on :root, then reference it with font-size: var(--type-base); throughout your stylesheet. This gives you one place to change the scale globally.
Universal modern support: Chrome 79+, Firefox 75+, Safari 13.1+, Edge 79+. Global usage is above 96%. No polyfill is needed for any current browser. For very old browsers, the value degrades to the min size.