Type Scale Generator

Pick a base font size and a ratio (1.25 major third, 1.333 perfect fourth and others) to get a matched set of heading and body sizes, previewed with real text and exported as CSS tokens.

Modular Type Scales Explained: Ratios, Font Sizes and Building a Hierarchy

Look at a well-designed website and the font sizes feel related: headings step down in a steady rhythm, and nothing looks randomly chosen. Often that’s because the sizes come from a modular type scale, a sequence where each size is the previous one multiplied by a fixed ratio. It’s a simple idea that removes most guesswork from typography.

Modular type scale with font sizes from 16 to 49 pixels using a 1.25 ratio

How a modular scale works

Pick a base size, usually your body text (16px is the default in browsers). Pick a ratio. Multiply up for larger sizes and divide down for smaller ones:

With a base of 16px and a ratio of 1.25:

StepCalculationSize
−216 ÷ 1.25 ÷ 1.2510.24 px
−116 ÷ 1.2512.8 px
0 (base)1616 px
+116 × 1.2520 px
+220 × 1.2525 px
+325 × 1.2531.25 px
+431.25 × 1.2539.06 px
+539.06 × 1.2548.83 px

Because each step grows by the same proportion, the sizes feel harmonious. The difference between steps is also relative, which matches how we perceive size: going from 16 to 20px feels similar to going from 40 to 50px.

The idea was popularised for the web by Tim Brown’s “More Meaningful Typography” (2011) and his Modular Scale calculator, building on centuries of typographic practice where printers worked with traditional size sequences.

Choosing a ratio

Many common ratios are named after musical intervals, because a musical interval is also a frequency ratio:

RatioNameCharacterGood for
1.067Minor secondVery subtle stepsDense data apps
1.125Major secondSubtleDashboards, admin tools
1.2Minor thirdBalancedProduct UI, documentation
1.25Major thirdClear hierarchyMost websites
1.333Perfect fourthStrongMarketing sites, blogs
1.414Augmented fourthBoldEditorial, landing pages
1.5Perfect fifthDramaticHeadline-led layouts
1.618Golden ratioVery dramaticPosters, hero sections

Small ratios give you many usable sizes close together; large ratios give strong contrast but grow huge quickly. With a golden ratio scale, step 5 from 16px is already over 170px. The type scale generator above previews each ratio with your own sample text.

How many sizes do you need?

Fewer than you think. Most interfaces work well with five to seven sizes:

  • a small size for captions, labels and metadata,
  • body text,
  • one or two subheading sizes,
  • two or three heading sizes.

Every extra size makes it harder to keep the design consistent. If you find yourself needing a size between two steps, that’s often a sign the hierarchy should be expressed with weight, color or spacing instead.

Size isn’t the only tool for hierarchy

Typographic hierarchy comes from contrast in several properties:

PropertyExample
Size32px heading vs 16px body
WeightBold heading, regular body
ColorDark heading, mid-grey metadata
Case and spacingSmall uppercase labels with letter spacing
SpaceMore space above a heading than below it

A modest ratio combined with weight and spacing often produces a cleaner hierarchy than a dramatic ratio alone.

Mobile versus desktop

A ratio that looks great on a wide screen can make mobile headings enormous. A common solution is to use a smaller ratio on small screens (say 1.2) and a larger one on desktop (say 1.333), and interpolate between them with CSS clamp(). Our guide to fluid typography with clamp() shows the formula. Body text barely changes; headings scale smoothly.

px versus rem

Define your scale in rem units: 1rem equals the root font size, 16px by default. If a user increases their browser’s default font size for readability, every rem-based size scales with it. Pixel sizes don’t respond to that setting. Our px vs rem guide explains the details.

Rounding

Scales produce numbers like 31.25px or 39.06px. Browsers handle fractional sizes fine, so there’s no technical need to round. Rounding to whole pixels (or to multiples of 2 or 4) can make design files and handoff tidier. Both approaches are fine; consistency is what matters.

Line height goes with size

As font size increases, line height (as a ratio) should decrease. Body text reads best around 1.5; large headings look better around 1.1–1.25, because big type already has visually large gaps between lines. Use unitless line heights so they scale with each size. Our line height calculator helps choose values.

From scale to tokens

Turn the final sizes into named tokens:

:root {
  --text-sm: 0.8rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.563rem;
  --text-2xl: 1.953rem;
  --text-3xl: 2.441rem;
}

Names like sm, base and xl (as used by Tailwind CSS) are easy to remember and don’t need renaming if you change the ratio later.