Design CSS Grid layouts visually with live preview and code export.
This CSS grid generator lets you build a grid layout visually: set the columns, rows, gaps and alignment, watch a numbered live preview update, then copy the finished CSS. It suits developers and designers who want a clean starting point for a page or card layout without writing grid code by hand.
CSS Grid is a two-dimensional layout system that places content into rows and columns at the same time. You turn an element into a grid container with display: grid, describe the tracks (the columns and rows), and the browser drops each child element into a cell.
A few terms come up constantly when you work with grid:
The fr unit is a fraction of the free space left in the grid container after fixed sizes and gaps are subtracted. In 1fr 2fr, the second column gets twice as much of the leftover width as the first.
The minmax() function sets a minimum and a maximum size for a track. A column of minmax(200px, 1fr) never shrinks below 200px, but it can grow to share the remaining space equally with other columns.
Grid controls rows and columns together, while Flexbox lays items out along a single line. Use grid for page structure, galleries and dashboards. Use Flexbox for a nav bar, a button group or anything that flows in one direction. Many layouts use both: grid for the outer frame and Flexbox inside each cell.
You can go from a blank grid to copyable code in under a minute. Every control updates the preview and the code instantly.
200px 1fr 2fr.Set both sliders to 2 for a 2x2 grid, or leave them at the default 3 and 3 for a 3x3 grid. Keep the template on Equal Fractions and the output gives you equal-width columns and automatic row heights, ready to paste.
Say you want eight product cards in two rows of four, with a little more space between columns than between rows. Set Columns to 4, Rows to 2, Column Gap to 20 and Row Gap to 10. Leave the template on Equal Fractions, keep justify-items on stretch, and set align-items to center.
The preview shows eight blocks numbered 1 to 8, and the Generated CSS reads like this:
.grid-container { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, auto); column-gap: 20px; row-gap: 10px; justify-items: stretch; align-items: center; }
Here is what that means in practice. In a 1000px-wide container, the three column gaps take 60px, which leaves 940px. Each of the four columns is then 235px wide. Rows are only as tall as their content, and each card sits in the vertical middle of its row.
Choose Custom and enter 200px 1fr 2fr. In a 1000px container with 10px column gaps, the first column is fixed at 200px. The remaining 780px is split 1 to 2, giving 260px and 520px. This is a typical pattern for a sidebar plus two content areas.
Each control maps to one line of the output, so you can tune a single value and see exactly which line changes. The table below summarizes the four column template choices.
| Template | What you get | Best for |
|---|---|---|
| Equal Fractions | Same-width columns | Simple galleries |
| Auto | One column sized to content | Stacked content |
| Responsive (minmax) | Columns at least 200px wide that grow equally | Card layouts |
| Custom | Your own track list | Sidebars, mixed widths |
justify-items moves items left to right inside their cell, while align-items moves them top to bottom. Stretch fills the whole cell and is the default behavior. Start, end and center shrink each item to its content and pin it to that position. If your blocks suddenly look smaller after you change an alignment, that is expected: they no longer stretch.
A good layout has gaps that feel consistent, columns wide enough for their content, and no horizontal overflow. As a widely used guideline, gaps between 16px and 24px suit card layouts, while 8px to 12px suit dense dashboards. The sliders stop at 40px, which covers most real designs.
A responsive grid changes its column count as the container gets narrower. The Responsive (minmax) option sets each column to at least 200px, but it uses the fixed column count from the slider. On a very narrow screen, those columns can overflow instead of wrapping.
For true wrapping, choose Custom and enter repeat(auto-fit, minmax(200px, 1fr)). The browser then fits as many 200px-plus columns as the width allows and wraps the rest onto new rows. With auto-fill, empty columns are kept so items hold their size. With auto-fit, empty columns collapse and the remaining items stretch to fill the row.
For layouts that must change structure at set widths, pair the grid with breakpoints from a CSS media query generator. For example, use 1 column below 600px, 2 columns up to 900px and 4 columns above that.
Anyone who needs a layout skeleton quickly gets value from a visual grid builder. Typical situations include:
Most problems with generated grids come from a few predictable mistakes, and each has a quick fix.
200px, 1fr, minmax(150px, 1fr) or repeat(3, 1fr), separated by spaces, with no semicolons or braces.200px 1fr 2fr, is intentional. Use repeat(N, 1fr) for identical widths.minmax(0, 1fr) in a Custom template so the track is allowed to shrink.Rename the .grid-container class to something meaningful, such as .product-grid, before you ship it. Once the CSS is in your stylesheet, a CSS formatter keeps it readable while you work, and a CSS minifier shrinks it for production. If your project uses Sass, the Sass to CSS converter helps when you move rules between formats.
This tool builds the container-level rules of a grid: columns, uniform rows, gaps and item alignment. It does not create named grid areas, make individual items span several columns or rows, or set per-item placement.
Rows are always generated as automatic height, so each row grows with its content. The preview uses numbered placeholder blocks of a fixed height, which means your real content may change row heights. When you need a hero that spans the full width, add grid-column: 1 / -1 or grid-column: span 2 to that item by hand after pasting the CSS.
Once the grid is in place, you can style the cells with a CSS box shadow generator for card depth. More helpers for front-end work are collected in the web developer tools section.
A visual builder removes the guesswork from grid syntax: you see the layout, adjust it and copy clean CSS in seconds. Use the CSS grid generator on this page to set your columns, rows and gaps now, then paste the result into your project.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market