Spacing Scale Calculator
Turn a 4px or 8px base into a spacing scale, check existing values against it, and export the tokens for design-system code.

Use this spacing calculator to turn a 4px or 8px base unit into a short set of values for gaps, margins, and padding. A linear spacing scale follows value = base unit × step. Ratio-based scales compound from the base when the layout needs larger jumps.
Choose a preset or set your own base unit, then test the generated tokens in a real layout. Use the value matcher to replace an existing measurement with the nearest token. Copy that reference, or open Code to export the full scale.
Maaz Rana builds and maintains this tool for Design Overflow. Updated .
Loading Spacing Calculator...
Why Spacing Systems Matter
Give repeated layout decisions a shared set of values
Visual Consistency
A short set of repeated values keeps related components aligned and makes one-off gaps easy to spot during review.
Faster Development
Named tokens replace repeated debates over values such as 12px and 16px. Designers and developers can refer to the same scale.
Better Hierarchy
Small gaps group related controls. Larger gaps separate sections and make the page structure easier to scan.
Improved Accessibility
Spacing gives text room to reflow and gives controls enough separation. Target size still needs its own accessibility check.
Easier Maintenance
A token change can update each component that references it. Teams can revise the scale without searching for every copied value.
Team Alignment
Shared names let a designer specify `space-4` and let a developer use the same value in code and documentation.
Understanding Grid Systems
4-point vs 8-point grids and when to use each
4-Point Grid System
A 4-point grid uses multiples of 4 pixels (4, 8, 12, 16, 20...) as the foundation for spacing. This system offers fine-grained control over spacing decisions, making it ideal for dense, information-heavy interfaces.
Best For
- Complex dashboards
- Dense data tables
- Desktop applications
Benefits
- Granular control
- High flexibility
- Precise alignment
8-Point Grid System
An 8-point grid uses multiples of 8 pixels (8, 16, 24, 32...) for all spacing decisions. This system creates bold, clear spacing with fewer decision points, reducing cognitive load for both designers and developers.
Best For
- Mobile apps (iOS/Android)
- Marketing websites
- Clean, minimal UIs
Benefits
- Faster decisions
- Natural scaling
- Cross-platform consistency
Best Practices for Spacing
Test the scale in components before the team adopts it
Start with a Base Unit
Choose 4px or 8px as the base, then test the resulting values against the components you have.
If unsure, start with 8px for simplicity, or use 4px if you need more granular control.
Limit Your Token Count
Start with enough tokens to cover common component and page gaps. Add a value after several real uses need it.
Keep a token when two or more components need it. Record one-off values as exceptions.
Use Semantic Naming
Keep an indexed base scale and add semantic aliases for stable roles such as `page-gutter` or `control-padding`.
Create a two-tier system: base tokens (space-1) and semantic aliases (section-gap = space-8).
Document Usage Guidelines
Show each token in a component and state where the team uses it. A value list without examples leaves the decision unresolved.
Show actual components using each spacing value in the documentation.
Test at Multiple Breakpoints
Test the scale on narrow and wide layouts. Change section gaps when the layout needs it instead of scaling every token by one rule.
Reduce large section gaps on small screens when the layout loses too much room.
Consider Component-Specific Spacing
Buttons and fields may need internal padding outside the base pattern. Record the exception and keep it tied to the component.
For buttons, consider using one token for vertical padding and another for horizontal (e.g., 12px vertical, 24px horizontal).
Integrate with Typography
Test spacing beside real line heights and text lengths. A clean number sequence can still create poor vertical rhythm.
Place a 24px line height beside the candidate gaps and check the resulting paragraph and section rhythm.
Review and Iterate
Track which tokens appear in production and which remain unused. Remove choices that the team cannot distinguish in review.
Audit usage after several shipped screens. Remove unused tokens and add values that keep recurring.
Common Spacing Mistakes
Avoid these pitfalls when building your spacing system
Too Many Arbitrary Values
Using random spacing values (13px, 18px, 27px) instead of tokens creates inconsistency and makes maintenance difficult.
Commit to your spacing system. If a token doesn't exist for your needs, add it to the system rather than creating one-off values.
Not Considering Mobile
Spacing that works on desktop can feel too generous on mobile, wasting precious screen real estate.
Test your spacing scale on actual mobile devices. Consider responsive spacing where larger tokens scale down on smaller screens.
Ignoring Negative Space
Packing too much into layouts without adequate breathing room makes interfaces feel cramped and overwhelming.
Give sections enough separation to show the page structure. Check the result on narrow screens.
Inconsistent Scale Type
Mixing linear and modular scaling within the same system creates an unpredictable, jarring experience.
Choose one scale type for the base tokens and document any component exceptions.
No Team Documentation
Creating a spacing system but not documenting when to use each token leads to misuse and inconsistency.
Keep a style guide beside the design library and code documentation. Include usage examples for each token.
Forgetting Component States
Not accounting for how spacing changes in hover, focus, or active states can break your layout.
Test hover, focus, and active states while building the component. Keep outlines from changing its measured size.
How to Implement Your Spacing Scale
Step-by-step guide to using spacing tokens in your project
Generate Your Scale
Use the calculator above to create a spacing scale that matches your design needs. Start with a preset or customize from scratch.
Export to Your Format
Choose your preferred format (CSS variables, Tailwind, SCSS, etc.) and copy the generated code.
Add to Your Project
Paste the spacing tokens into your stylesheets or configuration files. For CSS variables, add to your :root or theme file.
Use Consistently
Reference your spacing tokens throughout your components instead of arbitrary values. This ensures consistency across your entire design.
Document & Share
Create documentation for your team explaining when to use each spacing token. Share the configuration URL for easy access.
Put the Scale Into Practice
Use the guides when you need to choose the grid, name the tokens, or move them into code
Spacing system guide
Choose a formula, test the scale, and introduce it without creating another abandoned rulebook.
4-point vs 8-point grid
Pick the right level of control for dense product screens or simpler layouts.
CSS spacing tokens
Carry the scale into custom properties and current Tailwind theme variables.
Sources used in this guide
Android documents its 8dp layout grid and 4dp treatment for smaller elements. MDN explains how CSS custom properties keep repeated values in one place. Tailwind documents how its spacing theme variable drives spacing utilities.
Frequently Asked Questions
An 8-point grid uses multiples of 8 for layout, component, and spacing decisions. Android uses an 8dp grid for most interface elements and a 4dp grid for smaller elements such as icons. A web design system can follow the same relationship in CSS pixels: use 8px for the main rhythm and allow 4px half-steps where compact components need them.
A modular spacing scale multiplies one base value by a fixed ratio at each step: value = base × ratio^step. A 4px base with a 1.5 ratio produces 4, 6, 9, 14, and 20 after rounding. Ratios near 1.25 leave more values for dense interfaces. Ratios near 1.5 create larger jumps for layouts with fewer spacing roles.
The Fibonacci option adds the previous two terms, then multiplies the sequence by your base unit. The ratio between consecutive terms approaches 1.618 as the sequence grows. The Golden Ratio option applies 1.618 at each step from the start. Fibonacci gives you uneven early steps; the Golden Ratio gives you one constant multiplier.
Use rem when spacing should follow the root font size. Use em when padding or gaps should follow one component's text size. Use px for measurements that must stay fixed, such as a one-pixel border. The calculator converts the same scale between these units with the root size you provide.
Generate the scale, choose an export format, and copy the result. CSS export returns custom properties under `:root`. Tailwind export returns spacing values for the framework. The tool also provides SCSS, JavaScript, JSON, and Design Tokens Community Group output for token pipelines.
Use indexed names such as `space-1` for the base scale, then add semantic aliases such as `page-gutter` for stable roles. Indexed names make scale changes easier to manage. Semantic names explain intent inside components. The calculator supports `space-`, `spacing-`, and `s-` prefixes.
The calculator generates fixed tokens in px, rem, or em. It does not generate viewport-based `clamp()` spacing. You can use two exported scales as the lower and upper bounds for a separate fluid calculation, but test the result in real components before replacing breakpoint rules.

Need the Scale Carried Into the Product?
Share the product and the places where spacing rules break down. Design Overflow can connect the scale to the components, design library, and production code.
Discuss the Design System