How do I use the grid generator?
Set how many columns and rows you want, choose a gap and an auto-flow direction, and the numbered items rearrange in the live preview. Change the item count to see what happens when items outnumber the explicit cells — the grid simply creates new rows for them. The CSS below the preview updates with every change: press Copy CSS, paste it into your stylesheet, and rename .container and .item to your own classes. Try the Sample for a 4 x 3 grid.
What is CSS grid?
CSS grid is the web's two-dimensional layout system: a container defines columns and rows, and items are placed into the resulting cells. Unlike older float and table hacks, grid was designed for layout from the start, with features like named areas, fractional sizing and automatic placement. It shipped in all major browsers in 2017 and quickly became the standard way to build page skeletons, galleries and dashboards.
Columns, rows and the fr unit
grid-template-columns and grid-template-rows define the tracks. This generator uses repeat() with the fr unit — a fraction of the free space — so repeat(3, 1fr) makes three equal columns that share the container width. Mixing units is common in real layouts: a 200px sidebar plus 1fr for the content, for example. The gap property sets consistent spacing between tracks, replacing the old margin hacks.
Grid vs flexbox: which should I use?
Choose grid when you need to control rows and columns together — overall page layout, photo galleries, dashboards, card collections. Choose flexbox when items flow in a single line and should size themselves — navbars, toolbars, button groups. Most production sites use both: grid for the page skeleton, flexbox inside components. If you are placing items into a table-like structure, grid is the natural fit.
Making grids responsive
The most useful responsive trick is repeat(auto-fit, minmax(200px, 1fr)): the browser fits as many columns of at least 200px as the screen allows, wrapping the rest automatically — no media queries needed. Combine it with a sensible gap and your gallery adapts from phone to desktop on its own. Start from the CSS this generator produces, then swap the fixed column count for the auto-fit pattern when you need fluid behaviour.
Is it free and private?
Yes. The grid generator is completely free, needs no sign-up, and runs entirely in your browser. Your settings and generated CSS are never uploaded or stored. It works on phones, tablets and desktop computers.