Spacing Scale Generator

A spacing scale is the short list of sizes your margins, paddings and gaps are allowed to use. Pick a base unit (4 px for fine control, 8 px for roomier layouts) and get the full scale, named the way Tailwind names its steps, as CSS variables in rem or px, the single Tailwind v4 setting that drives it, or JSON tokens for a design system. Already have your own sizes? Paste them and get rem variables for those too.

px

4px is the usual grid (Tailwind, Material); 8px for roomier layouts

px

16px unless your site changes it

Token values in
0.52px / 0.125rem
14px / 0.25rem
1.56px / 0.375rem
28px / 0.5rem
2.510px / 0.625rem
312px / 0.75rem
416px / 1rem
520px / 1.25rem
624px / 1.5rem
832px / 2rem
1040px / 2.5rem
1248px / 3rem
1664px / 4rem
2080px / 5rem
2496px / 6rem
32128px / 8rem
Code
:root {
  --space-0: 0;
  --space-0_5: 0.125rem;
  --space-1: 0.25rem;
  --space-1_5: 0.375rem;
  --space-2: 0.5rem;
  --space-2_5: 0.625rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;
}

Separate with commas or spaces

Code
4px = 0.25rem
8px = 0.5rem
12px = 0.75rem
16px = 1rem
20px = 1.25rem
24px = 1.5rem
32px = 2rem
48px = 3rem
64px = 4rem

Calculating runs in your browser. What you type never leaves this device.

Features

  • Scale from any base unit, with Tailwind-style step names (0.5, 1, 1.5, 2 ... 32)

  • Visual bars so you can see the jumps between steps

  • Export as CSS variables (rem or px), Tailwind v4 --spacing or JSON design tokens

  • Any root font size for the rem values

  • Paste your own list of px values and get rem values and CSS variables

Who needs a spacing scale

Design systems

One agreed set of spacing tokens shared by designers in Figma and developers in code.

Tidying an existing site

Paste the margins and paddings your CSS already uses and turn them into a short list of named variables.

Tailwind projects

Change the base unit of every p-*, m-* and gap-* class in Tailwind v4 with one line.

Spacing scales explained

4 px or 8 px?

  • 4 px gives fine steps (4, 8, 12, 16...) and is what Tailwind and many app design systems use.
  • 8 px gives fewer, bigger steps (8, 16, 24, 32...), which keeps marketing pages airy and consistent.
  • Whichever you pick, use only sizes from the scale: the layout looks calmer when every gap is related.

rem or px tokens?

rem tokens grow when a reader raises the browser font size, which keeps spacing in proportion with bigger text. px tokens stay fixed. rem is the common choice for websites; the rem values here are the px values divided by the root font size.

Using the export

  • CSS variables: paste the :root block and write padding: var(--space-4).
  • Tailwind v4: paste the @theme line into your main CSS file; p-4 then equals four base units.
  • JSON tokens: import into Style Dictionary, Tokens Studio or your own build step.

Related tools

Spacing Scale Generator - FAQ