CSS Grid Generator is a free online visual builder for CSS Grid layouts. Set the number of columns and rows, control the size of each track independently, adjust column and row gaps, and click any cell to define a named grid area and fill it with stacked elements — headings, paragraphs, buttons, links, images, and dividers — reordered with simple up/down controls. Copy complete, production-ready CSS and matching HTML markup instantly, with live desktop, tablet, and mobile preview built in.
CSS Grid and Flexbox solve related but distinct layout problems, and knowing which to reach for saves a lot of fighting with the wrong tool. Flexbox is fundamentally one-dimensional — it excels at distributing items along a single row or column, which is why it's the right choice for a navbar, a button group, or a list of tags. Grid is two-dimensional by design: it lets you define both rows and columns simultaneously and place content into specific cells or named regions, which is exactly what you need for a full page layout with a header, sidebar, main content area, and footer, or for a card gallery that needs to align items across both axes at once.
The fr (fractional) unit is central to how this tool sizes columns and rows, and it behaves differently from a plain percentage. A track defined as 1fr claims one "share" of whatever space remains after fixed-size tracks (like 200px or auto columns) have taken their portion — so grid-template-columns: 1fr 2fr splits the remaining space into thirds, with the second column getting two of them. This makes proportional layouts trivial to express without doing percentage math by hand, and it's why fr is the default unit this tool reaches for.
Named grid areas — set by typing a name into any cell's Area Name field — compile down to the grid-template-areas CSS property, which lays out your grid visually as a small ASCII grid of names directly in your stylesheet. This is one of the most readable parts of the entire CSS Grid specification: a two-row layout with a full-width header, a sidebar, and a main content area reads almost like a diagram in the generated CSS, which is far easier to reason about six months later than a layout built purely from numeric column and row indices.
Every layout also needs to degrade gracefully on smaller screens, so the generated CSS includes tablet and mobile breakpoints automatically — collapsing to a two-column layout under 1024px and a single column under 640px, with named grid areas suspended at those breakpoints so content simply stacks in source order rather than fighting a grid definition that no longer makes sense at that width. Everything — the visual editing, the live preview, and the code generation — runs in your browser with no account or server round-trip required.