Modular Scale Calculator
Create modular scales for harmonious typography and spacing in web design using mathematical ratios.
Scale Settings
Multiple bases create a double-stranded scale
Scale Values
3.78px
0.2361rem
6.11px
0.3820rem
9.89px
0.6180rem
16.00px
1.0000rem
25.89px
1.6180rem
41.89px
2.6179rem
67.77px
4.2358rem
109.66px
6.8535rem
177.42px
11.0890rem
287.07px
17.9420rem
464.48px
29.0302rem
751.53px
46.9708rem
CSS Custom Properties
:root {
--ms-0: 0.2361rem; /* 3.78px */
--ms-1: 0.3820rem; /* 6.11px */
--ms-2: 0.6180rem; /* 9.89px */
--ms-3: 1.0000rem; /* 16.00px */
--ms-4: 1.6180rem; /* 25.89px */
--ms-5: 2.6179rem; /* 41.89px */
--ms-6: 4.2358rem; /* 67.77px */
--ms-7: 6.8535rem; /* 109.66px */
--ms-8: 11.0890rem; /* 177.42px */
--ms-9: 17.9420rem; /* 287.07px */
--ms-10: 29.0302rem; /* 464.48px */
--ms-11: 46.9708rem; /* 751.53px */
}SCSS
$ms-base: 16;
$ms-ratio: 1.618;
@function ms($n) {
@return nth($ms-base, 1) * pow($ms-ratio, $n);
}What Is a Modular Scale?
A modular scale is a sequence of numbers that share a consistent mathematical ratio — a single multiplier that connects every value in the sequence to the one before it. In web design and typography, modular scales give you a principled system for choosing font sizes, spacing values, and layout dimensions so that every measurement feels visually related rather than arbitrary.
The concept was popularized in CSS and typography circles by designer Tim Brown, and it draws inspiration from centuries of musical theory, architectural proportion, and classical geometry. When you apply a modular scale to a website, you are essentially encoding harmonic proportion directly into your design tokens. The result is a layout that feels balanced and intentional even to viewers who cannot articulate exactly why it looks so good.
This modular scale calculator lets you set a base value (typically your body text size, most commonly 16 px), select a mathematical ratio from a palette of classical intervals — including the iconic Golden Ratio (1.618) — and instantly generate an entire scale spanning negative steps (smaller sizes) through positive steps (larger sizes). You can also add a second or third base value to create a double-stranded or triple-stranded scale, interweaving two harmonic sequences for even richer typographic variety.
The output of this calculator is immediately practical: you get pixel values for every step, their rem equivalents (pixel value ÷ 16), ready-to-paste CSS Custom Properties, and a matching SCSS function you can drop into any Sass workflow. Whether you are building a design system from scratch or refining an existing component library, a modular scale gives you a defensible, systematic foundation for all your sizing decisions.
The Modular Scale Formula
Every value in a modular scale is calculated from the same straightforward exponential formula. The calculator applies this formula for every integer step n in the range you specify (default: −3 to 8), producing a full scale in one pass.
The rem conversion divides the pixel result by 16, matching the browser default of 1 rem = 16 px. This makes it trivial to copy scale values into CSS properties that use rem units for accessibility-friendly, user-scalable text.
Negative step numbers produce values smaller than the base, while positive steps produce larger values. Step 0 always returns the base itself (because ratio0 = 1), making it a natural anchor for body copy. Steps 1, 2, 3 … are used for subheadings, headings, display type, and hero text; steps −1, −2 … are used for captions, labels, and fine print.
When multiple bases are provided, the calculator computes the full formula for every base at every step, then merges and sorts all results by value. Near-duplicate values (within 0.5 px of each other) are collapsed in the display so the scale remains readable.
Modular Scale Value
Where:
- value= Output size for step n, in pixels
- base= Starting size in pixels (e.g., 16 px for typical body text)
- ratio= The constant multiplier between consecutive steps
- n= Step index — a positive or negative integer, or zero
- rem= value ÷ 16 (browser-default rem conversion)
Choosing the Right Ratio for Your Design
The ratio is the single most important decision when building a modular scale. It controls how dramatically sizes change from one step to the next. A smaller ratio creates subtle, closely spaced values — ideal for dense UIs like dashboards or data tables where you need many distinct sizes without huge visual jumps. A larger ratio creates bold contrasts between steps — perfect for editorial sites, landing pages, or marketing materials where dramatic type hierarchy draws the eye.
This calculator ships with thirteen ratio presets drawn from Western musical intervals, all of which have been used extensively in web typography:
| Preset Name | Ratio Value | Character |
|---|---|---|
| Minor Second | 1.067 | Very subtle — tightly spaced sizes |
| Major Second | 1.125 | Gentle progression, good for long-form content |
| Minor Third | 1.2 | Comfortable for most apps and sites |
| Major Third | 1.25 | Classic web-typography default |
| Perfect Fourth | 1.333 | Strong hierarchy without extreme contrast |
| Augmented Fourth | 1.414 | ISO paper proportions (A-series) |
| Perfect Fifth | 1.5 | Bold, confident jumps |
| Golden Ratio | 1.618 | Mathematically aesthetic — very popular in design |
| Octave | 2.0 | Each step doubles — dramatic display contrast |
You can also drag the slider to any custom ratio between 1.067 and 2.5 if none of the presets suit your project. Many designers fine-tune slightly below a named ratio to rein in the contrast on high-step values.
Multiple Base Values and Double-Stranded Scales
A single-base modular scale is powerful, but it only produces one value per step. For complex design systems — particularly those that need to unify two distinct type scales (for example, a heading typeface and a body typeface with different optical sizes) — you can add a second or third base value to create a multi-stranded scale.
When you click Add Base, the calculator runs the same value = base × ratio^n formula independently for each base, then merges all resulting values into a single sorted list. The effect is that between every two consecutive single-base steps you now get an intermediate value derived from the second base, giving you approximately twice the granularity without abandoning the harmonic structure.
A classic pairing is 16 px + 18 px with the Perfect Fourth ratio. The 18 px strand fills in the gaps left by the 16 px strand, producing a rich palette of sizes that all maintain a coherent proportional relationship. You can add up to three bases in this calculator. More than three bases tends to collapse the scale into a near-linear progression, losing the harmonic feel that makes modular scales valuable in the first place.
Double-stranded and triple-stranded scales are especially useful when building design tokens for a large component library where you need fine-grained spacing options (padding, gap, margin) alongside bold typographic steps, all from a single principled system.
Using the CSS and SCSS Output
The calculator generates two ready-to-use code blocks that you can copy directly into your project.
CSS Custom Properties are emitted in the form --ms-0, --ms-1, --ms-2, … inside a :root {} block. Each property holds the rem value (e.g., 1.0000rem) with the original px value in a comment for reference. Using CSS variables means your entire scale is defined once in one place — change the base or ratio in this calculator, paste the updated block, and every token updates automatically throughout your stylesheet.
SCSS output gives you a $ms-base variable, a $ms-ratio variable, and a concise ms($n) function that recomputes any scale step on demand. This is ideal if you prefer to reference steps semantically in Sass (e.g., font-size: ms(2)) rather than importing a long list of custom properties.
Both outputs update live as you adjust the base, ratio, and range, so you can experiment freely and copy the final result when you are satisfied. The CSS approach integrates seamlessly with design-token pipelines (Style Dictionary, Theo) and component libraries (Tailwind CSS, Chakra UI, shadcn/ui), while the SCSS output suits traditional Sass-based workflows.
Design Best Practices for Typographic Scales
Choosing a modular scale is only the first step. Applying it well to an interface requires a few additional decisions that can make or break the result.
Anchor your base to your body size. For most web projects the body text sits at 16 px (the browser default, equal to 1 rem). Setting your base to 16 px means step 0 always matches your prose, step 1 is your smallest heading, and negative steps are available for supporting text like captions and labels. If your body type is set to 18 px for readability at large viewport widths, use 18 px as your base instead.
Limit the number of steps in use. Just because the calculator generates steps from −3 to 8 does not mean you should use all of them. Most sites need only four to six distinct type sizes; spacing systems typically use six to ten distinct values. Selecting too many steps reintroduces the arbitrary feel you were trying to avoid.
Test on real content. Mathematical elegance does not guarantee visual success. Render your actual headings and body copy at scale values before finalising your choice. A ratio that looks perfect on a specimen page may feel too tight or too loose on your real content in your chosen typeface.
Combine with a responsive strategy. On smaller screens you may want to shift down by one step (e.g., use step 3 where desktop used step 4) to keep display headings from dominating a narrow viewport. CSS Clamp and fluid typography techniques can interpolate between two scale values across a viewport range, giving you smooth, scale-respecting responsiveness.
Worked Examples
Golden Ratio Scale — Body & Heading Sizes
Problem:
Base = 16 px, Ratio = 1.618 (Golden Ratio). Compute values for steps −1, 0, 1, 2, and 3.
Solution Steps:
- 1Step −1: value = 16 × 1.618^(−1) = 16 × 0.6180 = 9.89 px → 0.6180 rem (fine print / captions)
- 2Step 0: value = 16 × 1.618^0 = 16 × 1 = 16.00 px → 1.0000 rem (body text anchor)
- 3Step 1: value = 16 × 1.618^1 = 16 × 1.618 = 25.89 px → 1.6180 rem (small heading / lead paragraph)
- 4Step 2: value = 16 × 1.618^2 = 16 × 2.6180 = 41.89 px → 2.6180 rem (section heading)
- 5Step 3: value = 16 × 1.618^3 = 16 × 4.2358 = 67.77 px → 4.2361 rem (hero / display heading)
Result:
A five-level typographic hierarchy ranging from 9.89 px (captions) to 67.77 px (hero display text), all sharing the mathematical harmony of the Golden Ratio.
Perfect Fourth Scale for a Content-Heavy Blog
Problem:
Base = 16 px, Ratio = 1.333 (Perfect Fourth). Generate the scale from step −2 to step 4.
Solution Steps:
- 1Step −2: value = 16 × 1.333^(−2) = 16 × 0.5628 = 9.00 px → 0.5628 rem (metadata labels)
- 2Step −1: value = 16 × 1.333^(−1) = 16 × 0.7502 = 12.00 px → 0.7502 rem (captions, footnotes)
- 3Step 0: value = 16 × 1.333^0 = 16.00 px → 1.0000 rem (body text)
- 4Step 1: value = 16 × 1.333^1 = 16 × 1.333 = 21.33 px → 1.3330 rem (H4 / sidebar headings)
- 5Step 2: value = 16 × 1.333^2 = 16 × 1.7769 = 28.43 px → 1.7769 rem (H3)
- 6Step 3: value = 16 × 1.333^3 = 16 × 2.3689 = 37.90 px → 2.3689 rem (H2)
- 7Step 4: value = 16 × 1.333^4 = 16 × 3.1577 = 50.52 px → 3.1577 rem (H1 / page title)
Result:
A gentle but clear seven-level scale from 9 px to 50.52 px. The Perfect Fourth ratio is widely recommended for blogs because the jumps are large enough to establish hierarchy without overwhelming the page.
Double-Stranded Scale with Two Bases
Problem:
Bases = 16 px and 18 px, Ratio = 1.5 (Perfect Fifth). Compute step 0 and step 1 for each base, then sort.
Solution Steps:
- 1Base 16, Step 0: 16 × 1.5^0 = 16.00 px → 1.0000 rem
- 2Base 18, Step 0: 18 × 1.5^0 = 18.00 px → 1.1250 rem
- 3Base 16, Step 1: 16 × 1.5^1 = 24.00 px → 1.5000 rem
- 4Base 18, Step 1: 18 × 1.5^1 = 27.00 px → 1.6875 rem
- 5Merged and sorted: 16.00 px, 18.00 px, 24.00 px, 27.00 px — four distinct sizes between steps 0 and 1 alone
Result:
The double-stranded approach inserts 18.00 px between the base and step 1 of the 16 px strand, giving you 18 px (secondary body/lead) and 24 px (small heading) as intermediate values — both harmonically related to the same Perfect Fifth ratio.
Tips & Best Practices
- ✓Start with the Perfect Fourth (1.333) or Major Third (1.25) if you are unsure — these ratios work reliably for most websites and are easy to justify to stakeholders.
- ✓Use step 0 for your body text and pick your H1 size by counting how many steps above body it feels right at — then let the scale fill in the rest.
- ✓For mobile-first designs, try a smaller ratio like Minor Third (1.2) on narrow viewports and switch to Perfect Fourth (1.333) or larger at breakpoints using CSS media queries or clamp().
- ✓When adding a second base, choose a value close to but not equal to your first base — 16 px + 18 px is a classic pairing that adds useful intermediate sizes.
- ✓Copy the CSS custom properties output and paste them into a :root block in your global styles file; you can then reference any scale step with var(--ms-N) anywhere in your project.
- ✓Avoid using more than 5–6 distinct type sizes on a single page; pick the scale steps you need and ignore the rest — having the full scale available does not mean you must use every value.
- ✓Negative steps (−1, −2, −3) are perfect for secondary text elements like captions, timestamps, and form helper text — they keep the type hierarchy tight without resorting to arbitrary pixel values.
- ✓Test your scale with real headings and paragraphs in your chosen typeface before committing — some typefaces with tall x-heights need a smaller ratio than optically thin typefaces.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Modular Scale Calculator?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various