CSS Grid Generator
Build a CSS grid visually: set columns, rows and gaps, drag across cells to place items, then copy the HTML and CSS.
Loading interactive tool…
About this tool
The CSS Grid Generator turns a visual grid into working code. Choose 1 to 12 columns and 1 to 12 rows, give every track its own size (fr, px, %, auto, min-content or minmax()), and set separate column and row gaps. Then drag across the preview with a mouse, or tap a start cell and an end cell on a touch screen or with the keyboard, to create a named item that spans those cells. Rename items, remove them one at a time or clear them all, and watch the preview update live. The CSS output contains the parent rule with display: grid, grid-template-columns, grid-template-rows and gap, plus one rule per item with its grid-area line numbers; the HTML output contains the matching parent and child elements. A second mode builds the responsive repeat(auto-fill, minmax(Npx, 1fr)) column pattern for card grids that reflow without media queries. Everything runs in your browser.
Why use it
Visual layout: drag across the preview to create items that span columns and rows.
Clean output: grid-template-columns, grid-template-rows, gap and a grid-area for each item, ready to paste.
Any track size: fr, px, %, auto, min-content or minmax, with invalid sizes flagged.
Works with mouse, touch and keyboard.
Includes the responsive auto-fill pattern for card grids.
How to use
- Set the number of columns and rows, and the column and row gaps in pixels
- Type a size for each column and row, such as 1fr, 200px, 25%, auto or minmax(100px, 1fr)
- Drag across preview cells, or select a start cell and then an end cell, to add an item that spans them
- Rename items in the Items list, or remove ones you no longer need
- Click Copy CSS and Copy HTML to paste the layout into your project
- Switch Mode to Responsive auto-fill columns for a card grid that reflows by minimum column width
When it helps
- Sketching a page layout with a header, sidebar and content area.
- Building a dashboard or gallery grid with items that span several cells.
- Learning how grid-area line numbers map to a layout.
- Generating a responsive card grid with repeat(auto-fill, minmax()).
Frequently Asked Questions
Which track sizes can I use?
How do I make an item span several columns or rows?
What CSS does it generate for each item?
Can I set different column and row gaps?
What happens to items when I reduce the column or row count?
Can I still build a responsive auto-fill grid?
Is my layout sent to a server?
Explore the category
Glossary
- Grid track
- A column or row of a CSS grid, sized with values such as 1fr, 200px or minmax(100px, 1fr).
- fr unit
- A fraction of the free space in the grid container, shared between fr tracks.
- grid-area
- Shorthand for an item’s start row, start column, end row and end column lines, such as 1 / 1 / 2 / 3.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.