Generate a consistent spacing scale from any base unit. Get CSS custom properties, a Tailwind config snippet, and an SCSS map all ready to paste into your design system. Built on the same principles used by Material Design, Ant Design, and Radix UI.
Linear, Fibonacci, and geometric scales — pick the growth curve that fits your design language
CSS variables, Tailwind config, and SCSS maps — copy and paste directly into your project
See your scale as visual blocks, padding previews, and gap demonstrations before you ship it
Set your base unit, choose a scale algorithm, and adjust the number of steps. The tool generates your full spacing scale with CSS variables, Tailwind config, and SCSS map — ready to copy.
1–32px
| Step | Token | px | rem | Tailwind | Visual |
|---|---|---|---|---|---|
| 1 | --space-1 | 8 | 0.5 | p-2 | |
| 2 | --space-2 | 16 | 1 | p-4 | |
| 3 | --space-3 | 24 | 1.5 | p-6 | |
| 4 | --space-4 | 32 | 2 | p-8 | |
| 5 | --space-5 | 48 | 3 | p-12 | |
| 6 | --space-6 | 64 | 4 | p-16 | |
| 7 | --space-7 | 96 | 6 | p-24 | |
| 8 | --space-8 | 128 | 8 | p-32 | |
| 9 | --space-9 | 192 | 12 | p-48 |
CSS Custom Properties
:root {
--space-1: 8px;
--space-2: 16px;
--space-3: 24px;
--space-4: 32px;
--space-5: 48px;
--space-6: 64px;
--space-7: 96px;
--space-8: 128px;
--space-9: 192px;
}Tailwind Config (tailwind.config.js)
// tailwind.config.js
module.exports = {
theme: {
extend: {
spacing: {
"2": "8px", // 0.5rem
"4": "16px", // 1rem
"6": "24px", // 1.5rem
"8": "32px", // 2rem
"12": "48px", // 3rem
"16": "64px", // 4rem
"24": "96px", // 6rem
"32": "128px", // 8rem
"48": "192px", // 12rem
},
},
},
}SCSS Map
$spacing: ( "space-1": 8px, "space-2": 16px, "space-3": 24px, "space-4": 32px, "space-5": 48px, "space-6": 64px, "space-7": 96px, "space-8": 128px, "space-9": 192px ); // Usage: padding: map-get($spacing, "space-3");
No account required — 100% free
Inconsistent spacing is the most common reason production UIs feel off even when the typography and color palette are solid. When every engineer picks their own margin values — 13px here, 22px there — the result is a layout that nobody can explain and nobody can maintain. A spacing scale solves this by giving your entire team a shared vocabulary: instead of debating pixel values, you debate step numbers. This tool generates that vocabulary in under thirty seconds.
A spacing scale is a predefined set of size values that you use exclusively for all layout decisions — margins, paddings, gaps, widths, and offsets. Instead of choosing from an infinite range of pixel values, you constrain every spacing decision to a fixed set: for example, 4, 8, 12, 16, 24, 32, 48, 64px. Every component in your UI uses only values from this list.
The result is visual harmony. Because every spacing value shares a mathematical relationship, elements naturally align across components and pages — even when different engineers build them. Spacing scales are the foundation of every mature design system, from Google's Material Design (8px base) to Apple's Human Interface Guidelines (4pt base) to Radix UI's primitives.
The 8px grid became the dominant standard for one practical reason: most screen sizes are divisible by 8. At 1x density, 8px aligns to whole pixels. At 2x (Retina), 8px maps to exactly 16 physical pixels. At 3x, it maps to 24. This means your layouts stay pixel-perfect across every display density without fractional rounding errors.
Used by: Tailwind CSS (default), iOS HIG, Ant Design
4, 8, 12, 16, 24, 32, 48, 64
High-density UIs, data tables, form-heavy apps, admin dashboards. Gives fine-grained control for tight layouts.
Used by: Material Design, GitHub, Stripe, Linear
8, 16, 24, 32, 48, 64, 96, 128
Consumer apps, marketing sites, SaaS products. The most common choice — generous spacing without going too large.
Used by: Bootstrap (rem-friendly), custom design systems
10, 20, 30, 40, 60, 80, 120, 160
Teams that prefer decimal rem values. 10px base means 1rem = 10px, making rem calculations trivial to do in your head.
The tool takes your base unit and applies a multiplier sequence to generate each step in the scale. You choose from three algorithms:
Every generated value rounds to the nearest whole pixel to prevent subpixel rendering artifacts. The tool also outputs the rem equivalent of each value (dividing by 16, the browser default font size) so you can use either unit in your actual CSS.
Tailwind's default spacing scale uses a 4px base with values from 0 to 96 (0 to 384px). You can extend it with your custom scale without replacing the defaults by adding your values to theme.extend.spacing in your config file. Values in extend merge with defaults rather than overriding them:
tailwind.config.js — extending the default scale
module.exports = {
theme: {
extend: {
spacing: {
"18": "72px", // 9 × 8
"22": "88px", // 11 × 8
"26": "104px", // 13 × 8
"30": "120px", // 15 × 8
},
},
},
}If you want to replace Tailwind's default spacing entirely with your custom scale, use theme.spacing (without extend). This is the right choice for mature design systems where you want to prevent engineers from using arbitrary values outside your scale. Use the copied Tailwind config output from this tool and paste it into either location.
In Tailwind v4, the config format changes to a CSS-based theme definition. You define your spacing scale using @theme in your CSS file, which maps directly to the CSS custom properties this tool also generates — making the two outputs complementary.
Knowing the theory is one thing. Seeing how a spacing scale applies to real interface decisions is another. Here are the conventions that experienced front-end teams use:
Use steps 2–4 of your scale (e.g., 8–16px) for spacing between related inline elements — icon-to-label gap, tag chips in a row, form field icon padding. Related items should feel grouped.
Example: gap-2 (8px) between icon and label in a button
Use steps 3–5 (12–24px) for the internal padding of most UI components — cards, buttons, form inputs, list items, and dropdowns. This is your most-used range.
Example: px-4 py-3 (16px / 12px) for standard buttons
Use steps 5–7 (24–48px) to separate distinct UI sections on the same page — the gap between a heading and a card grid, between form groups, or between a sidebar item.
Example: space-y-6 (24px) between form sections
Use steps 7–9 (48–96px) for major page sections — the vertical rhythm between hero, features, pricing, and footer sections on a marketing page.
Example: py-16 (64px) section padding on desktop
Both work well — the right choice depends on your UI density. Use a 4px base if you build dense, data-heavy interfaces like dashboards, admin tools, or data tables where fine-grained control matters. Use an 8px base for consumer applications, marketing sites, and content-focused products where more breathing room improves readability. Many teams use a 4px base with a convention that they only use even-numbered steps (4, 8, 16, 24...) in practice — giving them the flexibility of 4px increments with the visual discipline of an 8px grid.
A spacing scale is the mathematical system — the set of values and the rationale behind them. A spacing token is the named variable that references a specific step in that scale in your code. For example, --space-3 is a token. The token's value of 24px comes from the scale. Tokens are what engineers and designers reference in their work; the scale is what ensures those tokens form a coherent, intentional system. This tool generates both: the scale defines the values, and the CSS variables, Tailwind keys, and SCSS map names are the tokens.
Replace Tailwind's default spacing in tailwind.config.js using theme.spacing (not theme.extend.spacing) so only your scale's values generate utility classes. Enable a linting rule using eslint-plugin-tailwindcss to flag arbitrary values like p-[22px]. For CSS codebases, provide only the CSS custom properties and remove other spacing values — engineers can only use what exists. Document the scale in your design system docs and make it the fastest path to using spacing. Friction reduction is more effective than enforcement.
Yes. Figma's spacing system uses numeric values directly, so you add the pixel values from your generated scale as Spacing tokens in Figma's Local Variables panel (Figma Enterprise / Professional) or manually apply them as a reference table in your component documentation. If you use a design token tool like Style Dictionary, Token Studio, or Supernova, you can import the CSS custom properties output from this tool as your source of truth and sync it directly to Figma variables and your codebase simultaneously.
Spacing scales apply specifically to layout spacing — margin, padding, gap, and positional offsets. Type scales (font sizes and line heights) use a separate but related mathematical system. Most design systems keep these distinct: a spacing scale based on 8px multiples and a type scale based on a ratio like 1.25 or 1.333. Some designers derive both from a single base unit for maximum coherence, but this constraint can make the type scale feel too rigid. The most practical approach is to build your spacing and type scales independently, then verify they share enough common values to create visual harmony.
Whether you're starting a design system from scratch, migrating a legacy codebase to design tokens, or onboarding a new engineer who keeps using random margin values — a well-defined spacing scale is the single highest-leverage tool in your system. Generate yours above, copy the output, and eliminate spacing debates from your team permanently.
Free forever · No account · CSS, Tailwind & SCSS output
Every tool runs entirely in your browser no uploads, no servers, no accounts. Fast, private, and free forever.
Colors, typography, CSS, SVG & more
Generate beautiful color schemes using color theory algorithms monochromatic, complementary, triadic, and more.
Build stunning CSS gradients visually linear, radial, and conic and copy production-ready code instantly.
Discover expert Google Fonts combinations curated for optimal readability and aesthetic harmony.
Generate production CSS visually flexbox, grid, typography, border, and box shadow with live preview.
Upload, edit, optimize, and convert SVG files entirely in your browser. Export clean SVG or React JSX.
Images, accessibility, spacing & readability
Compress images up to 90% smaller WebP, AVIF, JPEG, PNG with filters, cropping, and rotation. 100% private.
Remove image backgrounds instantly using on-device AI no uploads, no account. Download transparent PNG.
Generate a mathematically consistent shadow elevation system and export CSS variables or Tailwind config.
Build a harmonious spacing scale based on mathematical ratios and export it as CSS or Tailwind config.
Preview and compare border radius values in real time across multiple shapes and sizes.
URLs, QR codes, tracking & security
Shorten any URL instantly with browser history, QR code export, and zero server tracking.
Custom QR codes for URLs, WiFi, vCards & more. Add colors, logo, download PNG or SVG.
Build GA4-ready UTM tracking URLs with smart presets, validation, and CSV history export.
Strip 50+ tracking parameters (UTM, fbclid, gclid, msclkid) with before/after comparison.
See how your URL appears on Twitter, Facebook, LinkedIn & WhatsApp. Check OG metadata.