CSS Grid Layout Generator

Generate a responsive CSS grid from editable settings or card and dashboard examples.

On-device No sign-up Free to use

Generate grid controls

Column model
?

Sets the fixed column count. In either model, Columns × Rows sets the number of sample cells.

?

Columns × Rows sets the sample cell count in the preview and copied HTML. Auto-fit can arrange those cells into a different number of rows.

?

At or below this viewport width, the grid uses the mobile column count. Use 0 for no media query.

?

Used by auto-fit. The minimum is capped at 100% of a narrower container.

Processed in your browser. Your inputs stay on this device.

Showing an example. Change the fields, then use generate grid to update it.

Result

Showing an example.

Build six sample cells in three columns, switching to one column at a viewport width of 768 pixels or less.

Generated a grid with 3 equal columns, a 16px gap and 6 cells. Below 768px it uses 1 column.

Loading the tool. Your result will appear here.

https://usefreetools.net/css-grid-layout-generator · 20 November 2026

Was this helpful?

How to use CSS Grid Layout Generator

  1. Choose Fixed number of columns or Fit as many as will go. Enter the fixed column count or the auto-fit minimum width.
  2. Set Rows and Gap in pixels. Columns × Rows determines how many numbered cells the sample and HTML contain, including in auto-fit mode.
  3. Set a viewport breakpoint and Mobile columns, or enter 0 for no media query. Compare the preview at wide and narrow browser sizes.
  4. Select Generate grid and copy the CSS and matching HTML. Replace the sample cells with real content and test in your actual container.

Example: CSS Grid Layout Generator

Build six sample cells in three columns, switching to one column at a viewport width of 768 pixels or less.

You add
Column model: fixed; Columns: 3; Rows: 2; Gap in pixels: 16; Stack at or below (pixels): 768; Mobile columns: 1; Minimum column width (pixels): 240
You get
Generated a grid with 3 equal columns, a 16px gap and 6 cells. Below 768px it uses 1 column.

Options

Fixed columns
Use 1 to 12 equal columns. Rows accepts 1 to 12 and writes the explicit row count for this mode; row heights follow the content.
Auto-fit columns
Choose a minimum width from 80 to 600 pixels. The CSS fits as many columns as the container allows and clamps the minimum to 100% of a narrower container. Columns × Rows still sets the sample cell count; the actual number of rows depends on available width.
Gap
Use a whole number from 0 to 64 pixels between tracks. The gap also uses space that columns must share.
Viewport breakpoint
At a viewport width at or below the selected 1 to 2000 pixels, a max-width media query uses Mobile columns, from 1 to 12. Set 0 to omit that rule. Auto-fit then continues responding to container width; fixed mode keeps its column count.

Supported inputs and limits

  • Whole-number inputs, up to 12 Columns and 12 Rows, producing at most 144 numbered sample cells.
  • Gap is 0 to 64 pixels, viewport breakpoint is 0 to 2000, and the auto-fit minimum is 80 to 600 pixels.
  • One optional max-width query sets the mobile column count.
  • The tool writes layout CSS and plain cell markup; it does not add cell styling, named areas, container queries or per-cell placement.
  • Real content can create additional rows or change their height.
More details

The preview uses its own panel width and the browser’s viewport breakpoint, which may differ from your final container.

Where your input is processed

This tool does not upload your inputs. See the limits for anything saved on your device.

A sample row count does not limit real content

The copied HTML contains Columns × Rows numbered cells. Fixed mode defines that many explicit rows, while auto-fit creates rows as needed. Adding more items can create implicit rows. Replace the sample with actual text and images before choosing final dimensions; the generator does not know their size.

Questions about CSS Grid Layout Generator

When should I use the fit-as-many model?

Use it for a list where the column count should follow the available container width. The selected minimum is clamped to the container if it is narrower. Above the optional mobile breakpoint, the browser fits as many tracks as space permits. Fixed mode gives a specified column count.

Why do the preview columns not match my own layout?

The preview box is as wide as the workspace panel and it swaps at the viewport breakpoint you set. A real container can be narrower, carry padding, or hold wider content, so fewer columns may fit there. Paste the rule into your stylesheet and check the element at its real size.

What does the breakpoint actually do?

At the selected viewport width or smaller, the max-width query uses Mobile columns. Set the breakpoint to 0 to omit that override. Fixed mode then keeps its count, while auto-fit still changes with available container width.

Does the numbered cell HTML ship with styling?

No. The HTML block is a plain wrapper with one div per cell so you can see the count at a glance. Replace the numbered divs with your own content, and add the cell styling in your stylesheet.

Page updated · Project managed by Tony Hines · Report a problem with CSS Grid Layout Generator