CSS Grid Generator
Tracks, Gaps and Named Areas

Design a grid and copy the CSS. Set column and row tracks in fr, px, percent, auto or minmax(), draw named areas by dragging, then copy grid-template-areas, the grid-area rules or Tailwind classes. 100% client-side. Zero data stored.

A glass grid panel with header, sidebar, content and footer cells above the code grid-template-columns: 1fr 2fr 1fr;

CSS Grid Generator Tool

Build a CSS Grid

Presets

Columns

Rows

Track sizes: 1fr, 200px, 25%, 12rem, auto, min-content, max-content, minmax(100px, 1fr), fit-content(300px), or one repeat(auto-fit, minmax(160px, 1fr)) track.

Draw named areas

Press and drag across the cells with a mouse, finger or pen. With the keyboard, arrow keys move between cells, Space or Enter starts a selection, the arrows stretch it, Enter creates the area and Escape cancels. Delete removes the area under the cursor.

Drag across the cells to draw a named area.

No named areas yet. The CSS below has only the tracks.

Dashed cells are placeholders so every track is visible. They are not part of the CSS.

CSS
 
Tailwind CSS
 

Tailwind grid-cols-3 means repeat(3, minmax(0, 1fr)), which is not the same as repeat(3, 1fr), so the template is an arbitrary value that matches the CSS exactly. The line labels are for reading; copy the classes after the colon. Tailwind 3 and 4.

Common Use Cases

Page Layouts

Draw a header, sidebar, main and footer and copy the template areas, the holy grail layout in one block of CSS.

Dashboards

Mix fixed and flexible tracks, span tiles across several rows and columns, and see the result before you write markup.

Responsive Galleries

Use repeat(auto-fit, minmax(160px, 1fr)) for a gallery that adds and removes columns on its own, with no media query.

Magazine Layouts

Give a feature story two rows and a wide banner a full row, with unequal columns that keep their proportions.

12-Column Systems

Start from twelve equal tracks with a gap and build your own spans on top, in plain CSS or Tailwind.

Learning Grid

Change a track or an alignment and watch the cells and the CSS move together, which makes the grid model click.

Grid Syntax Reference

Track Sizes

Size What it means
1frOne share of the free space
200px, 12rem, 25%A fixed length or a share of the container
autoAs big as the content needs, and it can stretch
min-contentThe narrowest the content can be
max-contentThe widest the content wants to be
minmax(100px, 1fr)At least 100px, at most one share
fit-content(300px)Content size, but never over 300px
repeat(auto-fit, minmax(160px, 1fr))As many 160px or wider columns as fit

A run of identical tracks is written as repeat() only when that is shorter than listing them.

Alignment Properties

Property What it aligns
justify-itemsEach item inside its cell, left to right
align-itemsEach item inside its cell, top to bottom
justify-contentThe whole set of columns inside the container
align-contentThe whole set of rows inside the container

The two content properties only matter when the tracks are smaller than the container, so give the grid a height and fixed track sizes to see align-content.

1fr is not always equal

1fr means minmax(auto, 1fr), so a wide item can stretch its column. Use minmax(0, 1fr) when you need columns that stay exactly equal.

Areas must be rectangles

A named area is one rectangle of cells. L shapes and areas that overlap are invalid CSS, so this tool will not draw them.

auto-fit and auto-fill

Both make as many columns as fit. With few items, auto-fit collapses the empty columns so the items grow, and auto-fill keeps them empty.

Related tools

For one-dimensional layouts use the Flexbox Playground, and round the corners with the Border Radius Generator.

Pro Tip: URL Parameters

Open the generator with a grid already loaded. Use ?preset= with holy, twelve, dashboard, gallery or magazine, or describe the grid with ?c= (columns), ?r= (rows), ?g= (gaps), ?a= (alignment), ?h= (height) and ?areas=. For example: /grid-generator/?preset=holy or /grid-generator/?c=200px~1fr&r=auto~1fr&areas=header.1.1.1.2~main.2.2.2.2

Tracks are joined by a tilde. g is row gap and column gap, a is justify-items, align-items, justify-content and align-content, h is a height in pixels or auto. Each area is name.row1.column1.row2.column2 with 1-based cell numbers. The link in your address bar updates only after you change something, and the Copy Link button builds it from your current grid.

Frequently Asked Questions

Why We Built This Grid Generator

Grid is the most powerful layout tool in CSS and the hardest to hold in your head. A template of tracks is one line, a template of areas is another, and the two have to agree on how many rows and columns there are. Most generators give you a grid of boxes and a block of numbers. We built one where you describe the tracks, draw the areas on the cells with your mouse, finger or keyboard, and see the real grid change in the preview.

The output is the shortest valid form: identical tracks collapse to repeat() only when that is shorter, defaults are left out, and every area gets a grid-area rule. You can copy the CSS, copy Tailwind classes that match it exactly, download a stylesheet, and share a link that restores the whole grid. Everything runs in your browser and nothing you design is uploaded.

The Grid Generator is part of RJL.io's collection of free developer tools. For one-dimensional layouts try the Flexbox Playground, round the corners with the Border Radius Generator, and build backgrounds with the Gradient Generator.

Is your site ready for Google and AI search?

The free SEO Analyzer checks any page in seconds - meta tags, structured data, AI crawler access - and tells you exactly how to fix each issue on your platform.