Small tools. Better flow.

CSS clamp calculator

Calculate fluid CSS sizes for a viewport range.

Usage guide

Your input stays in this browser.

Input & options

Text 1 MB

View code examples ↓

Result

Your result will appear here.

Code examples

Starting points for your own code. Run them in the environment shown below.

Node.js 22+ · ES module (.mjs)

Current inputs apply only to fields used by the example. Selected files are not embedded.

const minSize = 16, maxSize = 32;
const minWidth = 320, maxWidth = 1280;
if (maxWidth <= minWidth || maxSize < minSize) throw new Error("Invalid range");
const slope = (maxSize - minSize) / (maxWidth - minWidth);
const intercept = minSize - slope * minWidth;
console.log("clamp(" + minSize + "px, " + intercept.toFixed(4) + "px + " +
  (slope * 100).toFixed(4) + "vw, " + maxSize + "px)");

Put it to work

Calculate fluid CSS sizes for a viewport range.

Details that matter

Format and meaning

Linearly interpolates between viewport endpoints. Check text zoom in your target environment.

Supported scope and limits

Text 1 MB

Split inputs that exceed the limit. If a format or algorithm is unsupported, choose a tool that matches your requirements instead of silently changing the format.