Free CSS clamp() Generator
Generate a fluid CSS clamp() value for responsive typography and spacing. Set min/max size and viewport range, see a live preview, and copy the one-line CSS.
Rendered size at different viewports
clamp(min, preferred, max) scales a value fluidly with the viewport, then locks at the min and max. It replaces stacks of media queries for typography, spacing, and widths with a single line.
Common uses
- Create Fluid Responsive TypographyScale font sizes smoothly between mobile and desktop with one line.
- Fluid Margins & PaddingMake section spacing grow with the viewport instead of jumping at breakpoints.
- Replace Media Queries with clamp()Collapse stacks of breakpoint overrides into a single fluid value.
- Build a Fluid Type ScaleGenerate consistent clamp() steps for a design-system type scale.
- Fluid Hero & Display HeadingsMake big landing-page headlines scale dramatically yet safely.
How It Works
This tool computes CSS clamp() values using a hand-written linear interpolation formula β no libraries, no server round-trips. You enter two sizes and two viewport widths; the math runs instantly in your browser and produces a ready-to-paste clamp() expression with a vw-based preferred value that scales your type or spacing smoothly between those breakpoints.
- 1Linear slope calculationThe tool computes a pixel-per-pixel slope: (maxSize - minSize) / (maxViewport - minViewport). This slope is then converted to vw units by multiplying by 100, which is the core of how CSS viewport-relative scaling works.
- 2Intercept derivationAn intercept offset (in px or rem) is calculated so the linear function hits exactly your minimum size at the minimum viewport. Together, slope and intercept form the preferred value inside clamp() β the part that actually scales.
- 3Unit conversion and output formattingIf you choose rem output, every pixel value is divided by your configured root font size (default 16px) before being written into the clamp() string. A matching Tailwind arbitrary-value class is also produced, with spaces replaced by underscores per Tailwind's syntax.
- 4Live viewport slider previewA range slider lets you scrub from 320px to 1920px wide. At each position the same slope-and-intercept formula evaluates the clamped size in real time and renders sample text at that computed pixel size, so you can see the scaling behaviour before copying anything.
Related Tools
CSS Grid Generator
Visually design a CSS grid β tracks, units and gaps β and copy the generated CSS and HTML.
What Is My Screen Resolution
See your screen resolution in CSS and real pixels, window size, pixel ratio, colour depth, HDR, touch support and refresh rate, and copy it all.
Signature Maker
Draw a signature with your mouse, finger, or stylus, or type your name in a handwriting font, then export it as a transparent PNG or SVG.