Modular Scale Calculator
Generate a harmonious type scale using musical ratios. Outputs desktop and mobile sizes plus fluid clamp() values for fully responsive typography in one CSS line.
Modular Scale Calculator
▶ Type Specimen
▶ Export
CSS custom properties or Tailwind config. Drop into your :root or tailwind.config.js — all values use fluid clamp().
What is a modular type scale?
A modular scale is a sequence of font sizes where each step is the previous size multiplied by a fixed ratio. Just as a musical scale divides an octave into steps with consistent mathematical relationships, a modular type scale creates visual harmony through proportion. Starting from a base size (typically 16px — the browser default for body text), multiplying by 1.333 (Perfect Fourth) gives the next step up: 21.3px. Multiply again: 28.4px, 37.9px, 50.5px — a complete heading hierarchy from one calculation. The sizes feel related because they share the same underlying ratio.
Perfect Fourth, Perfect Fifth and other ratios
The ratio name comes from music theory. A Perfect Fourth (1.333) is the ratio between a note and the note four steps above it — harmonious without being overwhelming, it is the most popular choice for UI type systems. A Perfect Fifth (1.5) creates a more dramatic scale with larger jumps — better suited for editorial and marketing contexts than dense UI. The Golden Ratio (1.618) produces very large step differences and works best for poster and display type rather than body-copy hierarchies. A Major Third (1.25) is the subtlest of the common ratios — ideal for interfaces with many heading levels where the jumps need to be modest.
Fluid typography with CSS clamp()
clamp(min, preferred, max) is a CSS function that constrains a value within a minimum and maximum, using a viewport-relative preferred value in between. Applied to font sizes, it creates typography that scales fluidly with the viewport — no media query breakpoints needed. The formula is: clamp(mobile-size, base-size + viewport-slope, desktop-size), where the slope is calculated from the mobile and desktop sizes and the viewport range. This tool calculates the correct slope and offset for each step in the scale and outputs the complete clamp() expression for every heading level.
Frequently asked questions
What base font size should I use?
Which ratio is best for a design system?
Should I use px or rem for font sizes?
How do I implement fluid typography without clamp()?
vw between them. clamp() is the cleaner, single-declaration alternative and is supported in all modern browsers since 2021.