CSS Grid Generator screenshot

CSS Grid Generator

Build a grid container rule: equal columns, an auto row height and a gap, with the column count and both lengths checked.

Privacy First
0 Runs
Updated 2026-11-17
Runs in your browser
No sign-up, no upload

What the CSS Grid Generator does

Columns are equal fractions of the free space: repeat(n, minmax(0, 1fr)). The minmax(0, …) floor is deliberate, because a bare 1fr refuses to shrink below its content's minimum and overflows a narrow container.

Rows get one height through grid-auto-rows, so row two and row ten are the same height without listing every row.

This generates equal columns only. A named template, grid-template-areas, per-track sizes and item placement are not emitted — they need a layout decision this page cannot infer from three numbers.

How to use it

Set Columns, Row height (px) and Gap (px), or press Run with the defaults.

Read the CSS rule below: the column count is inside repeat(), and the row height is grid-auto-rows.

Change Columns and press Run again — zero, a fraction or a count above 24 is refused by name.

Worked example

Input:


Output:

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 120px;
  gap: 16px;
}

Why it runs in your browser

The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.

A grid container with the column count you choose, equal tracks, and an explicit row height so the layout is visible before any content exists.

The column count is checked as a whole number from 1 to 24: a fractional or absurd count is refused rather than written into `repeat()`.

What it does, and what it does not

Columns are equal fractions of the free space: `repeat(n, minmax(0, 1fr))`. The `minmax(0, …)` floor is deliberate, because a bare `1fr` refuses to shrink below its content's minimum and overflows a narrow container.

Rows get one height through `grid-auto-rows`, so row two and row ten are the same height without listing every row.

This generates equal columns only. A named template, `grid-template-areas`, per-track sizes and item placement are not emitted — they need a layout decision this page cannot infer from three numbers.

How to use CSS Grid Generator

Set Columns, Row height (px) and Gap (px), or press Run with the defaults.

Read the CSS rule below: the column count is inside `repeat()`, and the row height is `grid-auto-rows`.

Change Columns and press Run again — zero, a fraction or a count above 24 is refused by name.

What to Expect

Best for

  • Getting an equal-column grid rule quickly
  • Remembering the minmax floor that prevents overflow

Not ideal for

  • A named or asymmetric template, which needs more than a column count
  • Placing items, which is a per-child decision

What this tool keeps

  • Equal tracks with a zero minimum
  • One row height for every row

What may need cleanup

  • Replace `grid-auto-rows` when rows should size to content
  • Add item placement rules by hand

Common errors

  • The page refuses it: columns must be a whole number from 1 to 24

Example use cases

  • Starting a card grid
  • Checking that a 3-column layout has an explicit row height

Sample input

Grid options:

Sample output

CSS rule: .grid-container { …

Who this is for

  • Frontend developers writing layout CSS
  • Anyone moving a flex row onto grid

Frequently asked questions

Why `minmax(0, 1fr)` rather than `1fr`?

A bare 1fr has an automatic minimum equal to the content's min-content size, so a long word pushes the track wider than its share and the grid overflows. The zero floor removes that minimum.

What does `grid-auto-rows` do?

It sets the height of every implicit row, so you do not have to list each row. Replace it with grid-template-rows when rows should differ.

Can I choose unequal columns?

Not on this page. Equal columns are what a single column count can express; an asymmetric template is a layout decision you write by hand.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.