CSS Grid Generator

Build a CSS grid layout visually and copy the code.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

CSS Grid generator

This tool builds a CSS Grid container visually and gives you the display: grid rules to paste into your stylesheet. It is for developers who want a quick column/row layout without memorising grid-template syntax. Set the track count, choose the sizing unit, tune the gaps, and copy.

How it works

The generator writes a display: grid block with grid-template-columns and grid-template-rows built from repeat(count, size). The sizing unit you pick decides the track size: fr uses 1fr (each track shares leftover space equally), px uses fixed sizes (120px columns, 80px rows), and auto sizes each track to its content. The gap is written as two values — row gap first, then column gap — matching the CSS gap: <row> <column> shorthand. The preview is a real grid using the same template, filled with numbered cells.

Example

With 3 columns, 2 rows, row gap 12px, column gap 12px and the fr unit, the tool outputs:

display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 12px 12px;

This makes a 3×2 grid of equal cells with 12px spacing in both directions.

Unitgrid-template-columns (3 cols)Behaviour
frrepeat(3, 1fr)Equal, fills the container
pxrepeat(3, 120px)Fixed 120px columns
autorepeat(3, auto)Each column fits its content

Everything runs in your browser — nothing is uploaded.

Ad placeholder (rectangle)