CSS Grid Generator

Set columns, rows, gaps and alignment, preview the layout and copy the grid CSS. Start from a common column pattern and change it until it fits.

CSS Grid Generator

Website Tools

Runs locally in your browser.

Interactive grid builder — adjust columns, rows, gaps and alignment. Runs locally.
1
2
3
4
5
6
CSS

About the CSS Grid Generator

CSS Grid has completely transformed the way we design the web by giving us true two dimensional control. But coding a complex grid from scratch can sometimes be tiresome. You'll have to imagine the invisible rows and columns in your head while writing complicated CSS functions like repeat() and minmax().

This CSS grid generator removes the guesswork. It allows web developers and designers to build grid layouts visually. Watch your design take shape as you change properties and preview your CSS grid in real time. Then, click a button to copy all the CSS code you need to add the grid to a web page.

Key Features of CSS Grid Generator

  • Interactive grid builderNo more imagining how your grid will look. See a preview of your layout and its colored blocks update in real time as you change properties.
  • Advanced CSS Grid functionsAdd advanced CSS properties such as repeat(3, 1fr) in columns or minmax(80px, auto) in rows by simply using the dropdowns in the grid builder.
  • Spacing and alignment controlsUse a slider to control spacing between items in your grid and dropdowns to adjust the default alignment of your grid items both horizontally and vertically.
  • Fast and responsive layoutThe visual CSS grid builder works directly in your browser for faster results. There's no waiting around for pages to load as you fiddle with the sliders.
  • Export CSS code with a click of a buttonWhen your layout looks the way you want it to, simply click "Copy CSS" to copy all the CSS code to your clipboard or "Download" to save the code as a file on your device.

How to Use CSS Grid Generator

  1. Define your grid structure by clicking on your desired values in the Columns (grid-template-columns) and Rows (grid-auto-rows) dropdown.
  2. Use the gap slider to set the amount of spacing between the items in your grid.
  3. Set default behavior of your grid items (vertically and horizontally) by using the dropdowns of: align-items, justify-items and for full control of the grid itself: justify-content.
  4. Look at a preview of your numbered and colored squares at the bottom of the page to see if it looks the way you want it to.
  5. Once you're satisfied, click the Copy CSS button to copy the code to your clipboard or Reset to start over

CSS Grid Generator Examples

A three-column grid with the default gap.

Input
Default options
Result
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(80px, auto);
  gap: 12px;
  justify-items: stretch;
  align-items: stretch;
  justify-content: stretch;
}

CSS Grid Generator — Frequently Asked Questions

What is CSS Grid?
CSS Grid is a two-dimensional layout system native to web browsers. It allows developers to divide a web page into major regions and define the relationship in terms of size, position, and layer, between parts of an HTML layout built across both rows and columns.
What is the difference between CSS Grid and Flexbox?
The main difference between CSS Grid and Flexbox is that Flexbox is a one-dimensional system whereas CSS Grid is a two-dimensional system. This means that Flexbox can only lay out items either horizontally or vertically, but not both at the same time.
What does the "fr" unit mean?
The fr (fractional) unit is specific to CSS Grid. It is a way of specifying how many "fractions" of a given space each part of a grid should take up. So, a layout set to 1fr 1fr 1fr will create three equal width columns that will all expand and contract as the screen size changes.