Spacing Scale Calculator

Say the smallest and largest space you need, such as 4px to 64px, and how many steps. The page fills in the steps on your grid and writes them as CSS variables.

How it works

The page spreads your steps between the smallest and largest space. "Faster as they get bigger" multiplies each step by the same factor, so small steps stay close and large ones spread out. "By the same amount each time" adds the same number of pixels at every step.

Each value is then rounded to the nearest line of your grid, such as every 4px. Two steps can round to the same line; when that happens they are merged, and the page says how many.

The scale is written as --space-1, --space-2 and so on, in rem or px. The preview draws each step at its real width. Nothing leaves your browser.

How to use it

  1. 1 Type the smallest space, such as the gap between an icon and its label.
  2. 2 Type the largest space, such as the gap between page sections.
  3. 3 Choose the number of steps, how they grow, and the grid to snap to.
  4. 4 Check the bars in the preview, then copy the CSS.

Good to know

  • Seven or eight steps are enough for most products. More steps means more choices that look almost the same.
  • Write spacing in rem if your font sizes are in rem, so text and the space around it grow together.
  • Use the small steps inside components and the large ones between them. That split alone makes layouts look more ordered.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Turning scattered padding values into a spacing scale

An app that grew without a plan often has spacing values everywhere: 5px, 6px, 10px, 14px, 15px, 18px, 30px, 32px and more. Each was right where it was typed, but together they make the layout look slightly uneven. A spacing scale replaces them with a short list everyone shares. The useful first question is not "which values" but "what range": here the smallest gap is about 4px, between an icon and its label, and the largest is about 64px, between page sections.

Type 4 and 64, choose 7 steps growing faster as they get bigger, and snap to a 4px grid. The factor between steps is the sixth root of 16, about 1.59. The raw values are 4, 6.35, 10.08, 16, 25.4, 40.3 and 64, and on the 4px grid they become 4, 8, 12, 16, 24, 40 and 64. That is close to the scales many design systems arrived at by hand, which is a good sign the method fits how spacing is used.

Now map the old values onto the scale. 5px and 6px become 4px or 8px, depending on how tight the element should feel. 10px becomes 8 or 12, 14px and 15px become 16, 18px becomes 16 or 24, and 30px and 32px both become 24 or 40. Some layouts change slightly, and that is the point: two cards with 15px and 16px padding never looked deliberately different. With the CSS variables in place, the code reads padding: var(--space-4) rather than a number someone has to guess the reason for.

Even steps suit a smaller job. For button padding from 8px to 24px in 5 steps on a 4px grid, the scale is 8, 12, 16, 20 and 24. A growing scale over that range would bunch the small steps together and leave little difference between them. Try both in the preview: the bars make it easy to see whether the steps feel evenly spaced to the eye, which is what matters.

The calculator has limits. It writes one fixed scale; it does not make spacing grow with the screen, which the CSS clamp() Generator can do for a single value. The names are numbers, not roles such as "gutter" or "inset", because roles depend on your product. Snapping can merge steps, as the page reports, so the step count you ask for is a maximum. And the scale cannot decide where each value belongs; that is still a design choice made one component at a time.

Frequently asked questions

Why snap to a 4px or 8px grid?

Values on a shared grid line up with each other, and they stay whole pixels on screens that scale by 1.5 or 2. An 8px gap is 12 device pixels at 1.5 times, while a 7px gap would be 10.5. Many design systems use 8px for layout and 4px for small gaps.

Why did some steps disappear?

Two steps rounded to the same grid line, so they were merged. A growing scale packs its small steps closely, and a step of 4.6px still rounds to 4 on a 4px grid. Use fewer steps, a finer grid, or a larger smallest space.

Should the scale grow evenly or faster?

Faster growth matches how spacing is used: you need fine control between 4px and 16px, and only a few large values such as 40px and 64px. Even steps suit a narrow range, such as padding from 8px to 24px.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.