DevTools Logo

Modular Type Scale Generator

Modular Type Scale Generator

Build a typographic ramp from any base and ratio, preview every step, and export CSS variables, Tailwind config, SCSS or JSON. Fluid clamp() lines included.

Export

10 steps · css
:root {
  --step-xs: 0.56rem;
  --step-sm: 0.75rem;
  --step-base: 1rem;
  --step-lg: 1.33rem;
  --step-xl: 1.78rem;
  --step-2xl: 2.37rem;
  --step-3xl: 3.16rem;
  --step-4xl: 4.21rem;
  --step-5xl: 5.62rem;
  --step-6xl: 7.49rem;
  --step-xs-line-height: 1.5;
  --step-sm-line-height: 1.5;
  --step-base-line-height: 1.5;
  --step-lg-line-height: 1.4;
  --step-xl-line-height: 1.3;
  --step-2xl-line-height: 1.2;
  --step-3xl-line-height: 1.12;
  --step-4xl-line-height: 1.12;
  --step-5xl-line-height: 1.05;
  --step-6xl-line-height: 1.05;
}

Ramp

2 down · 7 up · ×1.333
SteppxremLeading
xs(-2)90.561.5
sm(-1)120.751.5
base(0)1611.5
lg(1)21.331.331.4
xl(2)28.441.781.3
2xl(3)37.932.371.2
3xl(4)50.573.161.12
4xl(5)67.424.211.12
5xl(6)89.95.621.05
6xl(7)119.867.491.05

Preview

Rendered at computed sizes
xs · 9pxHeading
sm · 12pxHeading
base · 16pxHeading
lg · 21.33pxHeading
xl · 28.44pxHeading
2xl · 37.93pxHeading
3xl · 50.57pxHeading
4xl · 67.42pxHeading
5xl · 89.9pxHeading
6xl · 119.86pxHeading

Everything is computed in your browser; nothing is uploaded.

Examples

Perfect fourth

Input
Base 16 px, ratio 4/3, steps −2…+7
Output
12 px at −1, 21.33 px at +1

The ratio is stored as an exact fraction so the classic 12 px sub-step is exact.

10 px root

Input
Base 1.25 rem, root 20 px, ratio 2
Output
25 px base, 50 px at +1

rem inputs are converted through the root field, which is used consistently in exports.

Fluid hierarchy

Input
16→24 px over 375→1440 px
Output
clamp(1rem, 0.824rem + 0.751vw, 1.5rem)

The same viewport anchors scale with the ratio for every step in the ramp.

Invalid ratio

Input
Custom ratio 0.5
Output
Validation error

Ratios must be greater than 1; the ramp and exports are withheld until the input is fixed.

About this tool

The Modular Type Scale Generator builds a repeatable typographic ramp from a base size and a ratio. Named musical intervals cover the usual choices from a minor second to the golden ratio, and a custom ratio field handles anything in between. Each step is computed by repeated multiplication or division from the base, then shown in pixels and rem using a configurable root size.

A live table and preview panel show every step, including a suggested line height that tightens from 1.5 on body text to 1.05 on display sizes. The preview renders real text at the computed size instead of a chart, so you can judge the hierarchy before exporting it.

Fluid mode solves a linear interpolation between two viewport anchors and two base sizes, emitting a clamp() declaration per step. Exports cover CSS custom properties, a Tailwind fontSize theme, an SCSS map and plain JSON tokens; all four use the same rounded values as the on-screen table.

What this tool does not do

  • The clamp() output assumes a linear interpolation in px and rounds the emitted rem and vw terms; tiny anchor drift can result at low precision.
  • Named presets cover the common Tailwind and heading scales; beyond those steps the tool falls back to numeric names.
  • The tool generates sizes and optional line-height suggestions only — it does not set font families, weights or letter spacing.

How to use this tool

  1. Set the base

    Enter a base size in px or rem and set the root font size used for rem conversion. Most projects use 16 px.

  2. Pick a ratio

    Choose a named interval or enter a custom ratio between 1.001 and 4; larger ratios produce a more dramatic hierarchy.

  3. Choose the range

    Use the steps down and steps up sliders for the number of sizes, then pick Tailwind or heading-style names.

  4. Add fluid sizing

    Turn on fluid mode and enter the minimum and maximum base sizes plus their viewport anchors to get clamp() lines.

  5. Export

    Switch between CSS, Tailwind, SCSS and JSON tabs, then copy or download the active export.

Use cases

Design-system setup

Define a hierarchy once and export tokens for CSS, Tailwind or SCSS without recalculating by hand.

Responsive type

Generate clamp() lines that interpolate smoothly between mobile and desktop anchors.

Design handoff

Share one ramp as JSON tokens so developers and designers work from identical numbers.

Export formats

FormatWhat you get
CSS variables:root block with --step-<name> values and optional line-height tokens
Tailwind configfontSize theme entries as rem strings or [size, { lineHeight }] pairs
SCSS map$type-scale map with an optional $type-leading companion map
JSON tokensAn array of name, step, px, rem, lineHeight and optional clamp fields

Decimal precision is shared by the table and exports, so there is no drift between the preview and the generated code.

Common mistakes

Mistake:Using a ratio slider value of exactly 1.

Fix:Every step would be identical; the tool requires a ratio greater than 1.

Mistake:Forgetting to match the rem root to the site's font size.

Fix:Set the root size field to the actual computed root px; a 62.5% root is 10 px.

Mistake:Setting the maximum viewport below the minimum in fluid mode.

Fix:The tool blocks the fluid output and asks you to swap the two anchors.

Frequently asked questions

Which ratio should I pick?

A major third (1.25) is subtle and suits dense interfaces, a perfect fourth (1.333) is the classic balanced choice, and a golden ratio (1.618) gives a dramatic editorial look. Start with the perfect fourth and change one control at a time in the preview.

How does clamp() fluid scaling work here?

You provide a base size at a minimum and a maximum viewport. The tool solves a straight line between those anchors, converts the intercept to rem and the slope to vw, and emits clamp(min, intercept + slope, max). Every step uses the same viewport anchors with its own size pair.

Should a type scale use rem or px?

rem is usually better because it respects the user's browser font-size setting. The base unit control accepts either, and the root size field controls the conversion; with a 10 px root, 1.6rem equals 16 px.

How many steps do I need?

Most sites need six to ten steps: a couple of small sizes for captions, a base size, and four or five display sizes. Steps down and steps up let you generate up to eight in each direction without editing the exports by hand.

Why does my Tailwind export use arrays for some sizes?

Tailwind accepts a [fontSize, { lineHeight }] pair. When line-height tokens are disabled the tool emits a plain rem string; when they are enabled it emits the pair so the suggested leading travels with the size.

Is anything uploaded when I use this tool?

No. The ramp, previews and exports are computed entirely in your browser from the values you type; there is no network call and no account required.