CSS Grid Generator
Create CSS Grid layouts visually — set columns, rows, gaps, and responsive sizing with a live preview, then copy ready-to-use grid CSS. Free.
💡 How to use
- Set the number of columns and rows, then adjust the gaps.
- Switch column sizing between equal
frunits, auto, or responsiveminmax(). - Copy the
.gridCSS and apply it to your container.
Free CSS Grid Generator
Create CSS Grid layouts visually and copy the code in one click. Set columns, rows, and gaps, switch between equal, auto, and responsive sizing, and preview the grid live — then paste ready-to-use CSS Grid code into your project. Free, no sign-up, runs in your browser.
What is CSS Grid?
CSS Grid Layout is a two-dimensional layout system that arranges content into rows and columns at the same time. Unlike flexbox, which works along a single axis, Grid lets you control both dimensions together, making it ideal for page layouts, image galleries, dashboards, and any design built on a structured grid. It replaced years of float-based and framework-based grid hacks with clean, native CSS.
Key CSS Grid properties
This generator sets the properties you apply to the grid container:
- display: grid — turns an element into a grid container.
- grid-template-columns — defines the number and size of columns.
- grid-template-rows — defines the number and size of rows.
- column-gap and row-gap — set spacing between tracks.
- The fr unit — distributes available space in flexible fractions.
How to use the CSS Grid generator
Building a grid takes seconds:
- Choose how many columns and rows you need.
- Set the column and row gaps.
- Pick a sizing mode: equal fr units, auto, or responsive minmax().
- Copy the generated grid CSS and apply it to your container.
Understanding the fr unit
The fr (fraction) unit is what makes Grid so flexible. Instead of fixed pixels, fr distributes the available space proportionally: grid-template-columns: 1fr 1fr 1fr creates three equal columns that share the row, while 2fr 1fr makes the first column twice as wide as the second. Because it is relative, an fr-based grid adapts smoothly to different container widths without media queries.
Building responsive grids without media queries
One of Grid's most powerful patterns is a responsive layout with no breakpoints at all. Using repeat(auto-fit, minmax(120px, 1fr)), the browser fits as many columns as will comfortably hold your minimum size, then wraps the rest to new rows automatically. Cards reflow from four across on desktop to one on mobile with a single line of CSS — select the responsive minmax option in the generator to see it.
Pro tip
Use Grid for the overall page or section structure — the two-dimensional skeleton — and flexbox for the one-dimensional content inside each cell, like a row of buttons. The two systems complement each other. For single-axis layouts, try our Flexbox Generator.
FAQ
Is this CSS Grid Generator free?
What is the difference between CSS Grid and Flexbox?
What is the fr unit in CSS Grid?
How do I make a responsive grid without media queries?
How do I add spacing between grid items?
Can I use CSS Grid for a whole page layout?
Does CSS Grid work in all browsers?
Related tools
Pro tip: pair this tool with CSS Box-Shadow Generator and CSS Flexbox Generator for a faster SEO workflow.