CODDY Tool

CSS Grid Generator

Design a CSS grid layout visually and copy the CSS.

Set up columns, rows and gaps on a live grid and copy the result. Includes presets for the layouts people actually build, including responsive cards that reflow with no media queries.

Everything you enter stays in this browser tab. Nothing is sent to our servers, logged or stored.

Loading tool…

About CSS Grid Generator

Grid is two dimensional, which is the whole reason to use it over flexbox: rows and columns line up with each other, so a page layout stays aligned without nesting containers inside containers.

The single most useful thing grid can do is repeat(auto-fill, minmax(200px, 1fr)). That one line says: fit as many columns as will fit at 200 pixels or wider, and share out the leftover space between them. It produces a responsive card layout that reflows at every width with no media queries at all, which is why it is set as the default here.

The fr unit is the other idea worth internalising. It is not a percentage — it is a share of whatever space is left after fixed tracks and gaps have been subtracted. That is why 240px 1fr gives a fixed sidebar beside a main area that absorbs everything else, and why it keeps working when you change the gap.

How to build a grid

  1. Start from a preset

    Equal columns, a sidebar layout, the holy grail, or responsive cards. Each is a real pattern rather than a demo.

  2. Adjust the tracks

    Edit grid-template-columns directly. The preview updates as you type.

  3. Copy the CSS

    Defaults are omitted from the output, so you get the shortest rule that produces what you see.

Units that matter in a grid

  • fr — a share of the space left over. 1fr 2fr splits the remainder one third to two thirds.
  • minmax(min, max) — a track that will not go below one size or above another.
  • auto — sized to the content in that track.
  • repeat(n, …) — shorthand for repeating a track pattern.
  • auto-fill and auto-fit — let the browser decide how many tracks fit, which is what makes a grid responsive without media queries.

Frequently asked questions

What is the difference between auto-fill and auto-fit?

auto-fill keeps empty tracks in place, so a single card stays at its minimum width. auto-fit collapses them, so that card stretches across the whole row. That one word decides whether a lonely item sits small or spans the container.

What does 1fr actually mean?

One share of the space remaining after fixed tracks and gaps are subtracted. It is not a percentage, which is why 240px 1fr keeps working when you change the gap while 240px 80% does not.

Grid or flexbox?

Grid when rows and columns must align with each other — a page layout, a gallery, a dashboard. Flexbox for a single row or column of items. Many real layouts use a grid for the page and flexbox inside individual cells.

Do I still need media queries?

Far less often. repeat(auto-fill, minmax(200px, 1fr)) handles most card layouts on its own. Media queries remain useful for changes that are not just about fitting, such as moving a sidebar below the content on a phone.

All Developer Tools

CSS Grid Generator is free to use with no account, no watermark and no usage limits. Last updated 14 August 2026.