Free CSS Grid Layout Generator

Free CSS grid generator: set columns and rows in fr, px or auto, adjust gaps, drag across cells to place items, then copy the grid CSS and HTML markup.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideCSS Grid Layout Explained: fr Units, minmax(), Lines and Areas →

About the CSS Grid Generator tool

CSS Grid is the most powerful layout system in CSS, able to build full page structures, dashboards and card galleries with a few lines of code. Its syntax, with track lists, fr units, gaps and line numbers, can still be hard to picture in your head, and a single off-by-one line number puts an item in the wrong place.

This CSS grid generator lets you design visually. Set the number of columns and rows and give each track a size such as 1fr, 200px, auto, min-content or minmax(100px, 1fr). Adjust the column and row gaps with sliders. Then click and drag across cells on the canvas to create an item spanning those cells; repeat to build a header, sidebar, main area and footer, or any other arrangement.

Each item gets a coloured overlay and an editable class name, and the tool writes the container CSS with grid-template-columns, grid-template-rows and gap, plus a grid-area rule with start and end lines for every item. Switch to the HTML tab to copy matching markup.

How to use CSS Grid Generator

  1. Use the + and − buttons next to “Columns” and “Rows” and type a size into each track box.
  2. Set “Column gap” and “Row gap” with the sliders.
  3. On the “Grid canvas”, click and drag across cells to create an item.
  4. Rename items in the “Items” list or remove them with the bin icon.
  5. Copy the code from the CSS and HTML tabs.

Features

Drag to place items

Select a rectangle of cells with mouse or touch to create a spanning grid item.

Flexible track sizes

Supports fr, px, %, rem, auto, min-content, max-content, minmax() and fit-content().

Up to 12 × 12

Add or remove columns and rows freely, with invalid sizes highlighted.

Named classes

Give each item a class name that is used in both the CSS and HTML.

CSS and HTML output

Get the container rules, item grid-area rules and matching markup.

When to use it

  • Lay out a classic header, sidebar, content and footer page.
  • Build a bento-style feature grid for a landing page.
  • Plan an admin dashboard with widgets of different sizes.
  • Create an image gallery where some photos span two cells.
  • Learn how grid line numbers and spans work.

Frequently asked questions

What does 1fr mean?

fr is a fraction of the free space in the grid container. Three columns of 1fr each take one third of the available width after gaps.

How do grid-area line numbers work?

grid-area: 1 / 2 / 3 / 4 means row start line 1, column start line 2, row end line 3 and column end line 4. Lines sit between tracks, so an item ending at line 4 fills column 3.

Should I use Grid or Flexbox?

Grid is best for two-dimensional layouts with rows and columns. Flexbox is simpler for one-dimensional rows or columns of items, such as toolbars.

How do I make the grid responsive?

Wrap the grid-template rules in media queries, or use repeat(auto-fit, minmax(200px, 1fr)) for columns that wrap automatically.

Can items overlap?

Yes. CSS Grid allows items to occupy the same cells; later items are drawn on top unless you change z-index.

Related tools