Free CSS Grid Generator With Live Preview & Tailwind v4 Output
Visual playground for CSS Grid — edit column and row tracks, set gap and alignment, see the result instantly. Supports 1fr, auto,minmax(), and the canonical repeat(auto-fit, minmax(...))responsive-card pattern.
stretch
stretch
Range: 1–24 items.
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto auto;
gap: 16px;
justify-items: stretch;
align-items: stretch;
}grid grid-cols-[1fr_1fr_1fr] grid-rows-[auto_auto] gap-4 justify-items-stretch items-stretchEditable Track Lists
Add or remove column and row tracks dynamically. Each track accepts 1fr, auto, fixed lengths, minmax(), repeat() — anything valid CSS Grid syntax permits.
Live Visual Preview
See exactly how your grid will render — track sizes, gaps, alignment — with adjustable cell count from 1 to 24. The preview uses real CSS, not an approximation.
CSS + Tailwind v4 Output
Get vanilla CSS or a Tailwind v4 class string using arbitrary-value syntax (grid-cols-[200px_1fr] etc.) for exact preview parity.
100% Client-Side
No accounts, no uploads, no tracking. The browser renders the preview exactly as your production code will. Works offline once loaded.
Two-Dimensional Layout, Tuned With Live Visual Feedback
CSS Grid is the most powerful layout primitive the web has ever had — it replaces float-and-clearfix hacks, the table-as-layout era, even most JavaScript layout libraries. But its expressive power means its syntax is wider than any other CSS property: fr units, minmax(),repeat(), auto-fit vs auto-fill, named areas, subgrid. Most developers learn Grid by typing syntax into devtools and refreshing. Our Free CSS Grid Generator shortcuts that learning curve: edit column and row track lists as a visual list, set gaps and alignment, watch the preview update on every keystroke, then copy the production-ready CSS or Tailwind v4 class string. Four presets cover the 90%-case layouts (responsive cards, sidebar + content, holy grail).
Pair this with our Flexbox Generator (one-dimensional layout inside grid cells), CSS Gradient Generator (backgrounds for grid items), CSS Box Shadow Generator (elevate grid cards), and the Glassmorphism Generator (frosted-glass overlays on photo grids).
Track Value Reference — What Each Means
| Value | Meaning | Use |
|---|---|---|
| 1fr | One fraction of available space | Equal-width columns; the most common track value. |
| 2fr / 3fr | Multiple of one fraction | Asymmetric columns — 1fr/2fr makes the second twice as wide. |
| auto | Track sizes to its content | Side bars or sidebars where width depends on text length. |
| min-content | Smallest size the content can be without overflow | Narrow columns that wrap text aggressively. |
| max-content | Width the content wants if given infinite room | Long-form columns that should NOT wrap text. |
| 200px | Fixed length | Sidebars with a known fixed width. |
| minmax(100px, 1fr) | At least 100px; share remaining space | Responsive columns that have a minimum width. |
| repeat(auto-fit, minmax(...)) | Repeat as many columns as fit | The famous responsive-grid one-liner for card layouts. |
CSS Grid vs Flexbox — Which to Use When
| Aspect | CSS Grid | Flexbox |
|---|---|---|
| Dimensions | Two — rows AND columns simultaneously | One — row OR column at a time |
| Sizing model | Container-driven — you define tracks explicitly | Content-driven — items size from their content |
| Best for | Page-level layout, photo galleries, dashboards | Nav bars, button rows, cards inside grid cells |
| Overflow handling | Explicit row/column boundaries | Wrap to new rows/columns automatically |
| Browser support | 98%+ globally (Chrome 57+, Safari 10.1+, FF 52+) | 99%+ globally (Chrome 29+, Safari 9+, FF 28+) |
Rule of thumb: if you can answer "how many rows and how many columns" before writing the CSS, use Grid. If item count or sizing varies dynamically along one axis, use Flexbox.
Six CSS Grid Recipes You Will Use Constantly
Responsive card grid
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr))
Sidebar + main content
grid-template-columns: 240px 1fr
Three equal columns
grid-template-columns: repeat(3, 1fr)
Hero with header & footer
grid-template-rows: 60px 1fr 40px
Magazine-style 12-col layout
grid-template-columns: repeat(12, 1fr); gap: 16px
Photo gallery with aspect
grid-template-columns: repeat(auto-fill, 200px); grid-auto-rows: 200px