induwara.lk
induwara.lkCSS · Front-end

CSS clamp() Fluid Typography Generator

Turn a min size, a max size, and two viewport widths into a copy-paste clamp() declaration for fluid, responsive type. See the equation, a live preview, and the rendered size at every breakpoint. No signup, runs in your browser.

By Induwara AshinsanaUpdated Jul 5, 2026
Fluid clamp() generatorfont-size · spacing · any length
px

Size on the smallest screen.

px

Size on the largest screen.

px

Width where min size is hit.

px

Width where max size is hit.

px

Browser default is 16px. Used for rem conversion.

Output unit

rem respects the user's browser font-size preference — the accessible default.

Presets
Your clamp() declaration
font-size: clamp(1rem, 0.8239rem + 0.7512vw, 1.5rem);

Underlying equation

Slope (m)
0.007512
px of size per px of viewport
vw coefficient
0.7512vw
V = m × 100
Offset (b)
13.1831px
= 0.8239rem (intercept)
Preferred value
0.8239rem + 0.7512vw
verified to ±0e+0px

Live preview

viewport 908px → rendered 20.00px
240px2560px

Fluid type scales smoothly.

Rendered size by viewport

ViewportPreferredRenderedState
320px15.59px16.00pxClamped to min
375pxendpoint16.00px16.00pxFluid
768px18.95px18.95pxFluid
1,024px20.88px20.88pxFluid
1,440pxendpoint24.00px24.00pxFluid
1,920px27.61px24.00pxClamped to max

Preferred is the raw fluid value; Rendered is what the browser paints after clamp() floors it at 16px and caps it at 24px. Endpoints hit your target sizes exactly.

Method follows the CSS-Tricks fluid-type derivation; clamp() behaviour follows the W3C CSS Values 4 spec and MDN. Sources are linked below the tool. All math runs in your browser — nothing is uploaded.

How it works

Fluid typography sizes text on a straight line between two points: a small size on narrow screens and a larger size on wide screens. The generator builds that line by linear interpolation and then wraps it in CSS clamp() so the browser never draws text smaller than your minimum or larger than your maximum. The derivation is the widely used CSS-Tricks fluid-type method; the clamp() behaviour follows the W3C CSS Values and Units Module Level 4 and MDN.

Let s₁ and s₂ be your min and max font sizes in px, and v₁, v₂ the min and max viewport widths in px. The tool computes:

  1. Slopem = (s₂ − s₁) ÷ (v₂ − v₁), the px of font gained per px of viewport.
  2. vw coefficientV = m × 100. Since 1vw equals 1% of the viewport width, a slope in px-per-px becomes 100·m in px-per-vw.
  3. Offsetb = s₁ − m × v₁, the constant term (the line's value at a zero-width viewport). Converted to rem it is b ÷ root.
  4. Preferred valueb + V·vw, the middle argument of clamp().
  5. Declaration clamp(s₁, b + V·vw, s₂), with each length shown in your chosen unit.

By construction the preferred term equals s₁ exactly at v₁ and s₂ exactly at v₂; clamp() then flattens it to the min below v₁ and the max above v₂. Terms are rounded to four decimal places to keep the output clean while staying sub-pixel accurate. To prove correctness, every value is derived a second way — by direct interpolation between the two endpoints — and the two results are checked to agree to under a millionth of a pixel before the declaration is shown.

Prefer remfor the min and max: it respects the reader's browser font-size setting, which a fixed px minimum would override. The generator converts px to rem using the root font size you enter (16px by default).

Worked examples

Body text — 16→24px across 375→1440px

clamp(1rem, 0.8239rem + 0.7512vw, 1.5rem)

  1. Slope m = (24 − 16) ÷ (1440 − 375) = 8 ÷ 1065 = 0.0075117
  2. vw coefficient V = 0.0075117 × 100 = 0.7512vw
  3. Offset b = 16 − 0.0075117 × 375 = 13.1831px → 13.1831 ÷ 16 = 0.8239rem
  4. Min = 16 ÷ 16 = 1rem, Max = 24 ÷ 16 = 1.5rem
  5. @375px: 13.1831 + 0.7512 ÷ 100 × 375 = 16.00px ✓
  6. @1440px: 13.1831 + 0.7512 ÷ 100 × 1440 = 24.00px ✓
  7. @320px (below min): 15.59px < 16 → clamped to 16px ✓

Hero heading — 32→64px across 320→1200px

clamp(2rem, 1.2727rem + 3.6364vw, 4rem)

  1. Slope m = (64 − 32) ÷ (1200 − 320) = 32 ÷ 880 = 0.036364
  2. vw coefficient V = 3.6364vw
  3. Offset b = 32 − 0.036364 × 320 = 20.3636px → 20.3636 ÷ 16 = 1.2727rem
  4. Min = 2rem, Max = 4rem
  5. @320px: 20.3636 + 3.6364 ÷ 100 × 320 = 32.00px ✓
  6. @1200px: 20.3636 + 3.6364 ÷ 100 × 1200 = 64.00px ✓

Negative-offset edge case — 10→40px across 1000→1400px

clamp(0.625rem, 7.5vw − 4.0625rem, 2.5rem)

  1. Slope m = (40 − 10) ÷ (1400 − 1000) = 30 ÷ 400 = 0.075
  2. vw coefficient V = 7.5vw
  3. Offset b = 10 − 0.075 × 1000 = −65px → −65 ÷ 16 = −4.0625rem
  4. Offset is negative, so it's shown as a subtraction: 7.5vw − 4.0625rem
  5. @1000px: −65 + 0.075 × 1000 = 10.00px ✓
  6. @1400px: −65 + 0.075 × 1400 = 40.00px ✓
  7. @800px (below min): −5px < 10 → clamped to 10px ✓

Frequently asked questions

Sources & references

The clamp() semantics and browser-support statement on this page were last verified against MDN and the W3C spec on 2026-07-05. The underlying math is pure CSS-spec interpolation and does not change over time.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.