⚡
usefultools.dev
📏

CSS Clamp Calculator

NEW

Generate fluid typography and spacing with CSS clamp() from min and max sizes and viewport widths.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

Slope: 0.8333vw · Intercept: 13.3333px

Fluid typography scales smoothly between screen sizes.

Size at common viewport widths
ViewportSize (px)Size (rem)
320px161
375px16.461.029
480px17.331.083
640px18.671.167
768px19.731.233
1024px21.871.367
1280px241.5
1440px241.5
1920px241.5
⚡

Quick Examples

Typical inputs and the results this tool produces.

px
16px–24px, 320–1280px
clamp(16px, 13.3333px + 0.8333vw, 24px)
rem
1rem–1.5rem, 20rem–80rem
clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)
Heading
32px–64px, 375–1440px
clamp(32px, 20.7324px + 3.0047vw, 64px)
Negative
8px–40px, 400–1200px
clamp(8px, -8px + 4vw, 40px)
Shrinking
24px–16px, 320–1280px
clamp(16px, 26.6667px - 0.8333vw, 24px)
📖

Overview

CSS clamp(min, preferred, max) returns the preferred value but never lets it go below min or above max. Fluid typography uses it to scale a font size, margin or padding smoothly between two viewport widths with no media queries: font-size: clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem).

The middle value is a straight line through two points: the size you want at the smallest viewport and at the largest. This calculator works out the slope as (maxSize − minSize) / (maxViewport − minViewport) and the intercept as minSize − slope × minViewport, then writes the slope in vw and the intercept in px or rem. Rem keeps the intercept tied to the user's font-size setting.

Enter the sizes, viewport widths, unit and property, and the result updates instantly, with a preview slider and a table of sizes from 320px to 1920px. Everything runs in your browser.

Why use this tool?

  • Exact slope and intercept maths, no guesswork
  • px or rem for both sizes and viewport widths
  • Live preview and a table of sizes at common viewports
  • Handles negative intercepts and shrinking sizes
  • Warnings for WCAG-unfriendly scaling ratios
⭐

Features

🧮

Exact maths

Slope in vw and intercept in px or rem, rounded to four decimals.

📐

px and rem

Choose the unit for sizes and viewport widths, with a configurable root font size.

🔍

Live preview

Drag a viewport slider to see the computed size and sample text.

📊

Size table

Computed px and rem at 320, 375, 480, 640, 768, 1024, 1280, 1440 and 1920px.

🏷️

Any property

Output for font-size, padding, margin, gap, width, height or line-height.

⚠️

Sanity checks

Warns about equal sizes, 2.5x+ scaling and swapped min/max.

🛠️

How to Use

1

Enter sizes

Type the minimum and maximum size, for example 16 and 24, and choose px or rem.

2

Enter viewport range

Type the viewport widths where scaling starts and stops, for example 320 and 1280.

3

Check the result

Read the clamp() value, the slope and intercept, the preview slider and the size table.

4

Copy the CSS

Press Copy CSS and paste the declaration into your stylesheet.

🤔

Frequently Asked Questions