↑

Free CSS Grid Generator

What this tool does

The CSS Grid Generator builds grid layouts visually in your browser. Set the number of columns and rows, choose a gap and auto-flow direction, and watch numbered items fill the live preview grid instantly. The ready-to-paste CSS is generated as you go — copy it straight into your stylesheet and rename the classes. Perfect for galleries, dashboards and page layouts. Free and private, right in your browser — no sign-up needed.

Live preview
Generated CSS
-
Grid cells
-
Items
Ready
Status

Let us know

Please share your experience with this tool.

Thanks for rating!
No ratings yet — be the first!

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.

FAQs

What does CSS grid do?

It lays items out in rows and columns at the same time, giving precise two-dimensional control for page layouts and galleries.

What is the fr unit?

A fraction of the free space in the container. repeat(3, 1fr) creates three equal columns that share the available width.

How do I make a responsive grid?

Use repeat(auto-fit, minmax(200px, 1fr)) so columns wrap automatically as the screen narrows — no media queries needed.

Grid or flexbox?

Grid for two-dimensional page layouts and galleries; flexbox for one-dimensional flows like navbars and button groups. Most sites use both.

Is my code stored?

No. Everything runs in your browser; your settings and CSS are never uploaded or stored.

Is it free?

Yes, completely free with no sign-up. Everything runs in your browser.


Author

Awais Arshad

Web Tools Developer & Content Creator at FastToolKit.