Grid Calculator
About this tool
About Grid Calculator
Set up a layout grid you can actually build. Enter the container width, number of columns, gutter and outer margin, and the calculator gives you the exact column width, the content width, and the width of common spans such as 3, 4 or 6 columns, so components snap to the grid in design files and in code. Start from presets for desktop (1440px, 12 columns), laptop, tablet (8 columns) and mobile (4 columns). With a 4-pt or 8-pt baseline selected, it tells you whether columns land on the baseline and suggests the nearest container width that makes them land exactly, and it warns when a gutter or margin is off-grid. A small snapping tool rounds any value to the nearest, lower or higher multiple of your unit. A scaled preview shows the columns, and the code tabs give you a CSS grid rule, CSS custom properties, or a Tailwind snippet with the same values. Everything is calculated instantly in your browser.
Built and maintained by Abhi JainUpdated
How to Calculate a Column Grid
- 1
Choose a preset or enter values
Pick Desktop, Laptop, Tablet or Mobile, or enter container width, columns, gutter and outer margin.
- 2
Pick a baseline
Choose the 4-pt or 8-pt baseline unit to check that values stay on the grid.
- 3
Read the results
See the column width, content width and span widths, and follow the suggestion if columns are off-grid.
- 4
Copy the code
Copy the CSS grid rule, CSS variables or Tailwind snippet.
Grid Calculator: questions and answers
How do you calculate column width?
Column width = (container − 2 × margin − (columns − 1) × gutter) ÷ columns. A 1440px container with 72px margins, 12 columns and 24px gutters gives (1440 − 144 − 264) ÷ 12 = 86px columns.
Why use a 12-column grid?
Twelve divides evenly into halves, thirds, quarters and sixths, so most layouts fit without awkward spans. Tablets commonly use 8 columns and phones 4.
Do columns need to be a multiple of 8?
Not strictly. Gutters, margins and component spacing matter most. Whole-pixel columns avoid blurry edges, and the calculator suggests a container width that makes columns land on your baseline if you want that precision.
How do I build this grid in CSS?
Use display: grid with grid-template-columns: repeat(12, minmax(0, 1fr)), set column-gap to the gutter and padding-inline to the margin, as in the CSS output. Children span columns with grid-column: span n.
Related Tools
- Spacing Scale GeneratorSpacing tokens on a 4 or 8-pt grid, t-shirt sizes or a ratio, as CSS variables or Tailwind.
- Golden Ratio CalculatorSplit a length in the golden ratio or find the matching part, with a φ sequence.
- Aspect Ratio CalculatorSimplify a ratio, resize while keeping proportions and get CSS aspect-ratio.
- Viewport Unit CalculatorConvert px to vw, vh, vmin and vmax for any screen size, and back.