Skip to content

Menu

CSS Grid Generator

Visual CSS Grid layout builder with column/row controls and cell spanning.

Runs entirely in your browserDesignFree, no sign-up
Loading tool

01What is CSS Grid Generator?

Most grids start the same way. You want a few equal columns, a few rows and some space between them, and you want the syntax right the first time. CSS Grid Generator writes exactly that container rule and shows it working before you copy it. You set five things. Columns and Rows take a whole number from 1 to 12. Gap takes pixels from 0 to 64. Col Size offers 1fr, auto, minmax(0, 1fr) or 200px, and Row Size offers 1fr, auto, minmax(100px, auto) or 150px. Anything you type outside those ranges is pulled back inside them, and decimals are rounded. An empty box falls back to the minimum. That matters because the CSS Grid Layout spec from the W3C only accepts a positive integer as the repeat count, so repeat(0, 1fr) would make the browser drop the whole declaration. The output is a single .grid-container rule with display: grid, grid-template-columns: repeat(n, size), grid-template-rows: repeat(n, size) and gap. Under the controls, the Preview builds a real grid from the same values and fills it with numbered cells. So what you see is the browser's own layout, not a drawing. Here is a quick example. Pick 4 columns, 2 rows, a 24 pixel gap, minmax(0, 1fr) for columns and auto for rows. You get repeat(4, minmax(0, 1fr)) and repeat(2, auto) with gap: 24px. The minmax version is handy when a long URL or a wide image sits in one cell. Plain 1fr has an automatic minimum, so that content can push its column wider than the others. With minmax(0, 1fr) the four columns stay equal. The preview also shows the cases that bite later. Choose 200px columns and a high column count and the grid gets wider than the panel, so it scrolls sideways. Choose auto rows and each row shrinks to fit its cell. There are real limits, and we would rather you know them up front. Every column gets the same size and every row gets the same size. The tool does not place or span items, write grid-template-areas, or produce auto-fill and auto-fit patterns. Nothing you set leaves the page, since the CSS is built from your inputs in the browser tab. Treat the output as a clean starting scaffold and add the specific parts by hand.

Front-end developers who need a correct equal-track grid container fast and want to see it render before pasting it into a stylesheet. The tool runs entirely in your browser, so your data never leaves your device.

02How to use CSS Grid Generator

  1. Type the number of Columns and Rows, each from 1 to 12
  2. Set Gap (px) between 0 and 64
  3. Pick a track size in the Col Size and Row Size dropdowns
  4. Look at the numbered cells in the Preview to check the layout
  5. Click Copy in the CSS Output panel and rename .grid-container to your own class

03Worked examples

Input: Columns 3, Rows 3, Gap 16, Col Size 1fr, Row Size 1fr (the defaults)
Result: .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 16px; }
This is what the page shows on load and after Reset.
Input: Columns 4, Rows 2, Gap 24, Col Size minmax(0, 1fr), Row Size auto
Result: .grid-container { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, auto); gap: 24px; }
minmax(0, 1fr) lets columns shrink below their content's minimum width, while plain 1fr can be pushed wider by long words or images.
Input: Columns typed as 20, Rows 0, Gap 100, Col Size 200px, Row Size minmax(100px, auto)
Result: grid-template-columns: repeat(12, 200px); grid-template-rows: repeat(1, minmax(100px, auto)); gap: 64px;
Trimmed to the three changed lines. Inputs are clamped to 1-12 columns and rows and a 0-64 px gap, because repeat(0, ...) is invalid CSS.
Input: Columns typed as 2.6, other settings default
Result: grid-template-columns: repeat(3, 1fr);
Trimmed to one line. Fractional counts are rounded to the nearest whole number.
Input: Columns 2, Rows 3, Gap 0, Col Size auto, Row Size 150px
Result: .grid-container { display: grid; grid-template-columns: repeat(2, auto); grid-template-rows: repeat(3, 150px); gap: 0px; }
A gap of 0 is written as 0px, which is valid CSS.

04Common use cases

  • Starting a product card list with three equal columns and a 16px gap, then adding item rules on top
  • Fixing a layout where one long word or URL stretches a 1fr column, by switching to minmax(0, 1fr)
  • Setting up a 12-column scaffold for a dashboard before placing widgets with grid-column spans
  • Checking how fixed 200px columns behave in a narrow container before shipping them
  • Giving gallery rows a minimum height with minmax(100px, auto) so short captions do not collapse them
  • Showing a junior developer what grid-template-columns, grid-template-rows and gap each control

05Tips

  • If one cell's content makes its column wider than the rest, switch 1fr to minmax(0, 1fr). Plain 1fr has a minimum of auto, so content can stretch it.
  • For a column count that adapts to width, replace the copied value with repeat(auto-fill, minmax(250px, 1fr)). The tool does not generate this, so edit it by hand.
  • auto-fill keeps empty tracks when items run out, while auto-fit collapses them so the existing items stretch. Pick auto-fit if you have few items.
  • Rows you do not declare are still created when items overflow. Their size comes from grid-auto-rows, which you can add next to the copied rule.

06Related concepts

grid-template-columns, repeat(), fr unit, minmax(), gap, auto-fill vs auto-fit.

Frequently Asked Questions

What is CSS Grid Generator?

CSS Grid Generator is a free, browser-based developer tool on AIDToolStack. Visual CSS Grid layout builder with column/row controls and cell spanning. It requires no installation or sign-up and works entirely in your browser.

Is CSS Grid Generator free to use?

Yes. No sign-up, no fees and no usage cap.

Does CSS Grid Generator store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Related Tools

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe