Skip to main content

Modular Scale Generator

Our typography & graphic design calculator teaches modular scale step by step. Perfect for students, teachers, and self-learners.

Share this calculator

Formula

Value = Base x Ratio^Step

Each value in the modular scale is calculated by raising the ratio to the power of the step number and multiplying by the base value. Step 0 is the base value, positive steps generate larger values, and negative steps generate smaller values. The ratio determines how dramatically values change between consecutive steps.

Worked Examples

Example 1: Design System Type Scale

Problem: Create a modular scale for a design system with 16px base, Major Third ratio (1.25), 6 steps up and 2 steps down. What are all the values?

Solution: Base: 16px, Ratio: 1.25 (Major Third / 4:5)\n\nStep -2 (xs): 16 x 1.25^-2 = 10.24px (0.64rem)\nStep -1 (sm): 16 x 1.25^-1 = 12.80px (0.80rem)\nStep 0 (base): 16.00px (1.00rem)\nStep 1 (lg): 16 x 1.25^1 = 20.00px (1.25rem)\nStep 2 (xl): 16 x 1.25^2 = 25.00px (1.5625rem)\nStep 3 (2xl): 16 x 1.25^3 = 31.25px (1.9531rem)\nStep 4 (3xl): 16 x 1.25^4 = 39.06px (2.4414rem)\nStep 5 (4xl): 16 x 1.25^5 = 48.83px (3.0518rem)\nStep 6 (5xl): 16 x 1.25^6 = 61.04px (3.8147rem)\n\nTotal range: 61.04 / 10.24 = 5.96x

Result: 9 values from 10.24px to 61.04px | Range: 5.96x | Major Third ratio

Example 2: Double-Stranded Scale for Editorial Layout

Problem: An editorial website needs a richer scale. Use bases of 16px and 20px with a Perfect Fourth ratio (1.333), 4 steps up. Generate the merged scale.

Solution: Primary strand (base 16):\n16 x 1.333^0 = 16.00px\n16 x 1.333^1 = 21.33px\n16 x 1.333^2 = 28.43px\n16 x 1.333^3 = 37.90px\n16 x 1.333^4 = 50.52px\n\nSecondary strand (base 20):\n20 x 1.333^0 = 20.00px\n20 x 1.333^1 = 26.66px\n20 x 1.333^2 = 35.54px\n20 x 1.333^3 = 47.37px\n20 x 1.333^4 = 63.14px\n\nMerged (sorted): 16, 20, 21.33, 26.66, 28.43, 35.54, 37.90, 47.37, 50.52, 63.14\n10 distinct values providing finer granularity.

Result: 10 values from 16px to 63.14px | Double-stranded provides 5 additional intermediate sizes

Frequently Asked Questions

What is a modular scale in design?

A modular scale is a sequence of numbers that relate to one another through a consistent ratio, creating a harmonious set of proportions for design decisions. Rooted in musical theory (where notes relate through mathematical ratios), modular scales provide designers with predetermined values for typography, spacing, layout, and other dimensional decisions. Instead of choosing arbitrary numbers, a designer picks a base value and a ratio, then generates all sizes mathematically. For example, with a base of 16px and a ratio of 1.25, the scale produces 16, 20, 25, 31.25, 39.06, and so on. This mathematical foundation creates visual harmony because all values share proportional relationships.

How do I choose the right ratio for my modular scale?

The ratio should match the visual character and practical needs of your project. Smaller ratios like Minor Second (1.067) or Major Second (1.125) produce subtle differences between steps, ideal for data-dense interfaces, dashboards, and applications where many distinct but similar sizes are needed. Medium ratios like Minor Third (1.2) and Major Third (1.25) offer a good balance for most web projects, providing enough contrast for clear hierarchy without extreme size jumps. Larger ratios like Perfect Fifth (1.5) or Golden Ratio (1.618) create dramatic, editorial-style contrasts suitable for marketing sites, portfolios, and print design where visual impact takes priority over information density.

What is a double-stranded modular scale?

A double-stranded modular scale uses two base values with the same ratio, creating a richer set of proportional values. For example, using bases of 16px and 18px with a 1.25 ratio generates two interleaved scales that provide more size options while maintaining mathematical harmony. This technique was popularized by designer Tim Brown and is useful when a single-stranded scale does not provide enough intermediate values. The second base might be derived from a meaningful proportion in the design, such as the body text size and the sidebar width. The resulting merged scale offers more flexibility while preserving the proportional relationships that make modular scales visually coherent.

How do modular scales relate to musical intervals?

Modular scales in design borrow directly from musical harmony, where notes relate through mathematical frequency ratios. The Perfect Fifth (2:3 ratio, or 1.5) produces the same proportional relationship between design values as between musical notes a fifth apart. The Golden Ratio (approximately 1.618) appears throughout nature and art. The Octave (2:1) doubles the value with each step, creating the most dramatic contrast. These musical intervals have been recognized as pleasing proportions for centuries, and their application to typography and layout leverages the same innate human preference for harmonic relationships. The terminology helps designers communicate about proportional systems using shared musical vocabulary.

How do I implement a modular scale in CSS?

The most maintainable CSS implementation uses custom properties (variables) on the root element. Define each scale value as a variable: --scale-0: 1rem; --scale-1: 1.25rem; --scale-2: 1.5625rem, and so on. Reference these throughout your stylesheet for font-size, margin, padding, and gap values. CSS preprocessors like Sass can calculate scale values automatically using a function. For example, you can create a Sass function that takes a step number and returns baseValue * pow(ratio, step). Modern CSS with calc() can approximate this but lacks a native power function. Several CSS frameworks and PostCSS plugins like postcss-modular-scale automate this process entirely.

Can modular scales be used for spacing and layout, not just typography?

Absolutely. While modular scales are most commonly associated with typography, applying the same scale values to spacing (margins, padding, gaps) and layout dimensions creates a unified proportional system across the entire design. Using scale values for component padding, section margins, grid gaps, and border radii ensures that every dimensional decision reinforces the same visual rhythm. For example, if your type scale step-2 equals 25px, using 25px as a standard spacing unit creates visual alignment between text hierarchy and spatial organization. This holistic approach to proportional design is a hallmark of well-crafted design systems and creates a subtle but perceptible sense of visual order.

References