b2KIT

Spacing Scale Generator

Generate a consistent spacing scale (4px, 8px, 12px...) using a base unit and ratio for design systems.

Tested tool guide Tested browser tools Checked August 16, 2026

What Spacing Scale Generator does, with a checked example

A design system holds together only if every margin, padding, and gap comes from one small set of numbers. This tool produces that set: enter a base unit and a ratio, and it returns a ladder of spacing values, each step multiplying the previous one by the ratio, the same modular-scale idea typographers use, applied to space. The output is meant to be copied into design tokens (CSS custom properties, Sass variables, a JSON token file) so every component draws on the same scale. The usual surprise: a ratio of 2 doubles each step (4, 8, 16, 32); it does not add the base (4, 8, 12).

Worked example

A concrete input and expected output from the current implementation.

Input

base: 4, ratio: 2, steps: 6

Expected output

4px, 8px, 16px, 32px, 64px, 128px

Each value multiplies the previous one by the ratio: 4 × 2 = 8, 8 × 2 = 16, and so on through six steps. The base is the first step, and the scale is geometric, so gaps between consecutive values widen as the scale grows.

How the result is produced

1

Base and ratio

The base anchors the scale: the first value equals the base itself, and every later value is the base multiplied by the ratio raised to the step number. A ratio of 2 doubles each step (4, 8, 16, 32); ratios near 1.25 or 1.5 keep steps close together, the way type scales stay close. Raising the ratio spreads the ladder outward; lowering it packs it tighter.

2

Token-ready output

The values come out with px units and as a plain numbered list, sized for copying into CSS custom properties, a Sass map, or a JSON design-token file. Because every value derives from two inputs, changing the base or the ratio regenerates the whole scale, so updating a design system's spacing is a two-number change rather than a hunt through every component.

Good uses

  • Starting a design system: generate the scale up front, name the values as tokens (space-1, space-2, and so on), and route every margin, padding, and gap through those tokens instead of hand-typed pixel values.
  • Auditing an existing UI: enter the base and ratio the current spacing most resembles, then compare the generated series against the values actually used; the off-scale stragglers are the inconsistencies to fix.
  • Building a two-tier scale: generate a coarse ladder (ratio 2) for page-level spacing such as gutters and section padding, and a fine ladder (ratio 1.25) for component-level padding, keeping the two as separate token groups.

Limits and checks

  • Fractional values: a ratio like 1.5 on a 4px base produces 13.5 and 20.25. Most systems round to whole pixels, and rounding each value independently can create visible jumps, so round, then re-check the series by eye before locking it into tokens.
  • A doubling scale is easy to misread as an incomplete linear one: 4, 8, 16, 32 looks like a 4, 8, 12, 16 series with values missing, tempting a hand-insertion of 12 and 20. Filling in linear values breaks the geometric rhythm; read the whole series before editing it.
  • High ratios run away: ratio 3 from a 4px base gives 4, 12, 36, 108, a ladder with a useless top end. The practical band for spacing is roughly 1.25 to 2; above that, the scale produces only a few usable small values.

Common questions

Which ratio should I pick?

It depends on the job. A ratio of 2 gives a sparse doubling ladder (4, 8, 16, 32, 64) that suits layout-level spacing; 1.25 or 1.5 give closely packed steps that suit padding inside components. A practical test: the scale should offer usable values across the 4-64px range your UI actually uses. If the ladder jumps past what you need, the ratio is too steep.

I already have spacing values in my app. Can this tool help?

Used in reverse, yes. Try candidate base and ratio pairs until the generated series lines up with the values you actually use; the values that fit neither a doubling nor a linear pattern stand out as the ones to standardize first. If nothing matches, the existing spacing is likely ad hoc, and starting from a clean generated scale is the fix.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools