Layout Grid Calculator
Columns, gutters and margins that add up — with CSS, Figma values and an overlay.
Grid
Baseline grid
Preview frame
A screenshot of your page goes under the grid, scaled to the container width. It stays on your device.
Result
Whole-pixel options
Span widths and column positions
| Columns | Span width | Column starts at |
|---|
Export
The columns and baseline as an image the size of the frame (1440 × 900 px), transparent around them — drop it on top of a mock-up in any editor.
About the Layout Grid Calculator
A column grid only works when its numbers add up: the container width must equal the margins plus the columns plus the gutters between them. Enter four of those values and this calculator finds the fifth — the column width, the gutter, how many columns fit, the margins or the container width — and shows the grid at once, with the width of every span and where each column starts.
Add a baseline grid, put a screenshot of your page underneath to check the build, and take the result where you need it: CSS grid code (fluid or fixed), a pure-CSS overlay for checking a page in the browser, CSS variables and JSON tokens, the settings for Figma, Sketch and InDesign, or a transparent PNG or SVG overlay. When the numbers give fractional pixels, the calculator suggests nearby grids that come out in whole pixels.
How to use it
- Pick a preset (a 1440 px desktop, Bootstrap containers, Material Design grids) or type your own container width, columns, gutter and margins.
- Under Calculate, choose what to work out — the column width by default. That field turns read-only and shows the result; the other four are your inputs.
- Check the preview and the span widths. If the columns are not whole pixels, click one of the whole-pixel options to apply it.
- Optionally turn on the baseline grid, set the frame height, or add a screenshot of your page to see it under the grid.
- Under Export, copy the CSS, the design-app settings or the tokens, or download the grid as a PNG or SVG overlay.
Examples
1440 px container, 12 columns, 24 px gutters, 120 px margins
78 px columns (1,200 px of content)
(1440 − 2 × 120 − 11 × 24) ÷ 12 = 936 ÷ 12 = 78.
1320 px container, 12 columns, 24 px gutters, 12 px margins
86 px columns
1440 px container, 12 columns of 67 px, 120 px margins
36 px gutters
(1440 − 240 − 12 × 67) ÷ 11 = 396 ÷ 11 = 36.
1440 px container, 80 px columns, 24 px gutters, 120 px margins
11 columns, 80 px left over (add 40 px to each margin)
1440 px, 12 columns, 32 px gutters, 80 px margins
77.33 px columns → margins of 82 px give 77 px columns
Common uses
- Setting up the column grid of a new website or app design before drawing anything.
- Matching a Figma layout guide to the CSS grid a developer builds, number for number.
- Checking a live page against the design with the CSS overlay or a screenshot under the grid.
- Working out how wide a 4-of-12 card or a 6-column image really is, gutters included.
The formula
For a container of width W with n columns of width c, gutters g between them and a margin m on each side:
- W = 2m + n·c + (n − 1)·g
- column width c = (W − 2m − (n − 1)·g) ÷ n
- gutter g = (W − 2m − n·c) ÷ (n − 1)
- a span of k columns is k·c + (k − 1)·g wide, because it takes in the gutters inside it.
The column count is the largest whole n for which the columns still fit; what is left over can go to the margins to keep the grid centred. Josef Müller-Brockmann’s Grid Systems in Graphic Design remains the classic book on designing with such grids.
Fluid or fixed CSS
The fluid code uses grid-template-columns: repeat(12, minmax(0, 1fr)) inside a container with a max-width and padding for the margins, so the columns share the space and shrink on smaller screens while the gutters stay fixed. minmax(0, 1fr) rather than plain 1fr matters: a bare 1fr track cannot shrink below its content (CSS Grid: a lone 1fr means minmax(auto, 1fr)), so one long word or wide image would widen its column. The fixed code writes the pixel widths of the columns — useful inside a media query when each breakpoint has its own grid.
The CSS overlay draws the columns (and the baseline) over your real page with two repeating gradients on a ::after element — no JavaScript — so you can compare the build with the design in the browser.
Where the presets come from
- Bootstrap 5.3: containers are 540, 720, 960, 1140 and 1320 px wide at its breakpoints, and gutters are 1.5rem (24 px) — half of it as padding on each side of a column, while the row’s negative margins cancel the container’s 0.75rem padding. Column content therefore starts 12 px from the container edge, which is the margin used here (containers).
- Material Design 2: its responsive layout grid uses 4 columns with 16dp margins and gutters on a 360dp phone, and 8 columns with 32dp margins and 24dp gutters at 600dp.
- Material 3 no longer prescribes column counts; it lays out panes, with 16dp margins in compact windows and 24dp margins and spacers from medium up. The Material 3 presets therefore use panes as columns and the spacer as the gutter.
- The desktop, laptop, tablet and phone presets are common starting points, not standards.
Baseline grids
A baseline grid is a set of horizontal lines a fixed distance apart, often 4 or 8 px. Text sits on it when line heights are multiples of that distance — the calculator lists the ones between 12 and 96 px — and spacing between blocks is a multiple too. In Figma, a Uniform grid layout guide with Size 8 gives an 8-point grid; in InDesign the setting is Increment Every under Preferences › Grids (baselineDivision in scripting).
Limitations
- All columns have the same width and both margins are equal; asymmetric and modular grids with columns of different widths are not covered.
- Values are in pixels (dp and pt work the same way as numbers); percentages and rem are not converted here.
- PNG overlays are limited to 16,384 px on a side and 40 million pixels; the SVG overlay has no size limit.
- Figma, Sketch and InDesign settings are typed by hand; the calculator cannot change files in those apps.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
How do I calculate the column width of a grid?
Subtract both margins and all the gutters from the container width, then divide by the number of columns: (1440 − 2 × 120 − 11 × 24) ÷ 12 = 78 px. A 12-column grid has 11 gutters, because gutters only sit between columns.
Why do my columns come out as fractional pixels?
Because the space left after margins and gutters is not divisible by the number of columns. CSS lays out fractional widths without trouble, but design apps round them, so the design and the build drift apart. Use one of the whole-pixel options: changing the margins or the container by a few pixels is usually enough.
How do I set this grid up in Figma?
Select the frame, add a layout guide, choose Columns and enter Count, Type Stretch, Margin and Gutter as listed under Export › Figma, Sketch, InDesign. With Stretch, Figma works out the column width from the frame width.
Do the margins include the gutters?
No. Here the margin is the space from the edge of the container to the first column. Some frameworks build margins from padding instead — Bootstrap puts half a gutter on each side of every column — but the visible result is the same distance, which is what the calculator uses.
What gutter should I use?
There is no single right value. Many design systems use a multiple of their spacing unit, such as 16, 24 or 32 px, and keep gutters narrower than the columns; Bootstrap uses 24 px. Wider screens usually get wider margins rather than wider gutters.
Is my screenshot uploaded?
No. The screenshot is drawn in your browser only, and the PNG is made on your device.