Skip to content

Menu

Spacing Scale Generator

Generate consistent spacing scales

Runs entirely in your browserDesignFree, no sign-up
Loading tool

01What is Spacing Scale Generator?

A spacing scale is the short list of margin, padding and gap values a design system allows. Without one, a codebase slowly fills up with 13px here and 18px there. This tool builds the list for you and writes it out as code you can paste. It has two modes. Linear multiplies the base by the step number, so a 4px base gives 0, 4, 8, 12 and onward. That is the familiar 4-point or 8-point grid. Geometric keeps step 0 at zero, makes step 1 equal to the base, and multiplies by the ratio after that. Every geometric value is rounded to a whole pixel. Here is a worked case. Pick Geometric, base 4, ratio 1.5 and 10 steps. You get 0, 4, 6, 9, 14, 20, 30, 46, 68 and 103 pixels. Step 3 is 4 times 1.5 squared, which is exactly 9. Step 4 is 13.5, which rounds to 14. The gaps widen as you go, which suits page sections more than button padding. Base accepts 1 to 16 pixels and Steps goes up to 20. The Ratio box is greyed out in linear mode. Each step shows up in a list with its value and a bar, so you can see the rhythm at a glance. Switch the unit to rem and every value is divided by 16 and shown to three decimals. That 16px figure is the default root font size in browsers. The scale is written two ways. The CSS Variables panel puts custom properties named --space-0, --space-1 and so on inside a :root block, as defined in the W3C CSS Custom Properties spec. The Tailwind Config panel writes a spacing object you can drop into a v3-style tailwind.config.js. Copy CSS copies only the variables, so select the Tailwind text by hand. Three presets load a full setup, mode included: geometric 1.5 on a 4px base, a linear 8px grid with 12 steps, and a linear 4px scale with 17 steps. That last one lines up with the 0.25rem steps in Tailwind's default spacing. Some honest limits. Small bases with low ratios round into duplicates, so base 2 with ratio 1.2 repeats 2 and 3. Names are plain step numbers, not t-shirt sizes. The ratio box isn't clamped, so a typed value below 1 makes the scale shrink. Nothing here leaves your browser tab, since it is all arithmetic on three numbers.

Front-end developers and design-system maintainers who need a consistent set of spacing tokens as CSS variables or a Tailwind spacing object. The tool runs entirely in your browser, so your data never leaves your device.

02How to use Spacing Scale Generator

  1. Set Base (px) and Steps.
  2. Click Linear or Geometric. In geometric mode, set Ratio.
  3. Click px or rem to choose the output unit.
  4. Read the step list and the bars to check the rhythm.
  5. Click Copy CSS for the variables, or select the text in the Tailwind Config panel to copy it.

03Worked examples

Input: Linear, base 4, 8 steps
Result: 0, 4, 8, 12, 16, 20, 24, 28 px (rem: 0.000 ... 1.750)
Each step is the base times the step number.
Input: Geometric, base 4, ratio 1.5, 10 steps (preset)
Result: 0, 4, 6, 9, 14, 20, 30, 46, 68, 103 px
13.5 rounds to 14 and 102.5 rounds to 103 before display.
Input: Geometric, base 4, ratio 2, 12 steps
Result: 0, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 px
Doubling from the base gets very large very quickly.
Input: Geometric, base 8, ratio 1.5, 8 steps, rem
Result: 0.000, 0.500, 0.750, 1.125, 1.688, 2.563, 3.813, 5.688 rem
Pixels are rounded first (40.5 becomes 41), then divided by 16 and shown to three decimals.
Input: Geometric, base 2, ratio 1.2, 8 steps
Result: 0, 2, 2, 3, 3, 4, 5, 6 px
Small base and ratio produce duplicate steps after rounding.
Input: Linear, base 8, 12 steps, rem (preset 8px Grid)
Result: :root { --space-0: 0.000rem; --space-1: 0.500rem; ... --space-11: 5.500rem; }
Trimmed CSS Variables output. The Tailwind panel uses the same values with keys '0' to '11'.

04Common use cases

  • Defining spacing tokens at the start of a new component library, before anyone writes a margin by hand
  • Replacing ad-hoc margins in a legacy stylesheet with --space-N variables during a refactor
  • Writing a custom spacing key for tailwind.config.js when a brand grid uses 6px or 8px steps
  • Showing designers a geometric scale next to a linear one so the team can pick a rhythm
  • Converting an agreed pixel scale to rem values for an accessibility review
  • Checking a scale for duplicate values before publishing it as design tokens

05Tips

  • Geometric scales grow fast. Ratio 2 with 12 steps ends at 4096px, so use fewer steps or a ratio near 1.5 for spacing you will actually apply.
  • Rounding to whole pixels can make neighbouring geometric steps equal when the base is small. Scan the list for repeats before you publish tokens.
  • Rem output assumes a 16px root. If your site sets html font-size to 62.5%, the rem numbers here won't match the pixel sizes you see.
  • Under theme.spacing in Tailwind v3 the object replaces the defaults, while theme.extend.spacing adds to them. Tailwind v4 configures themes in CSS, so use the custom properties there.
  • Presets don't change the px or rem toggle, so check the unit after loading one.

06Related concepts

Design tokens, 8-point grid, CSS custom properties, Tailwind CSS, Vertical rhythm.

Frequently Asked Questions

What is Spacing Scale Generator?

Spacing Scale Generator is a free, browser-based developer tool on AIDToolStack. Generate consistent spacing scales It requires no installation or sign-up and works entirely in your browser.

Is Spacing Scale Generator free to use?

Yes. No sign-up, no fees and no usage cap.

Does Spacing Scale Generator store my data?

No. It runs in your browser; nothing is uploaded.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe