CSS Grid Generator
Build a CSS grid with equal, responsive or custom columns, set the gaps, row height and alignment, see it live, and copy the CSS and HTML.
Reviewed 23 November 2026 · Free · No account needed
How to use
- Choose Equal columns, Responsive or Custom, then set the number of columns, the smallest column width or your own track list.
- Set the column gap and the row gap, and pick a fixed row height or let rows grow with their content.
- Choose justify-items and align-items, and set the number of items for the preview.
- Press Copy CSS or Copy HTML to take the result.
Example
Input: 3 equal columns, 16px gap
Output: .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
How it works
Your choices are kept as one object. The preview is drawn from it with inline styles and the CSS text is built from the same values, so what you see is what you copy. A custom track list is checked before it is used.
Equal: grid-template-columns: repeat(n, 1fr). Responsive: repeat(auto-fit, minmax(min, 1fr)). Gap: gap: row-gap column-gap, written as one value when both are equal. Rows: grid-auto-rows: height, or left out for auto.
Three equal columns with a 16px gap gives .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }. Switching to Responsive with a 220 px minimum gives grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)).
Limits and edge cases
- Only the columns, the gaps, the row height and the item alignment are generated. Named areas and grid lines are not.
- A custom track list may use fr, px, %, em, rem, ch, vw, vh, auto, min-content, max-content, minmax(), repeat() and fit-content(), up to 160 characters.
- Equal columns go from 1 to 12, the preview shows 1 to 36 items, and the gaps go up to 100 px.
- The responsive mode uses auto-fit, which stretches the items to fill the row when there are fewer than fit.
- The 1fr unit means one share of the free space after fixed sizes and gaps are taken out.
- Responsive columns need no media query. They wrap to a new row when a column would be narrower than the minimum.
- A track list with an unknown word, an unclosed bracket or a character such as a semicolon is rejected with a message, and the preview falls back to three equal columns until the list is fixed.
- justify-items and align-items are left out when they are stretch, the default, unless you include default values.
Privacy
Everything is generated in this browser tab. Nothing you set is sent to a server or stored.
About this page
Written and reviewed by Toolnexo on 23 November 2026. The limits above describe the published tool, not an idealised version of it. If a result looks wrong or the page is unclear, email [email protected] with the tool URL and what you entered. Corrections are published here.
Guides that use CSS Grid Generator
Related tools
Questions about CSS Grid Generator
What does 1fr mean in CSS grid?
A fr is a fraction of the space left in the grid after fixed sizes and gaps are taken out. With three columns of 1fr they share it equally. With 1fr 2fr the second column gets twice as much as the first.
How do I make a responsive grid without media queries?
Use repeat(auto-fit, minmax(160px, 1fr)). The browser fits as many columns of at least 160 pixels as the width allows and shares out the rest, so the grid reflows as the window changes. Choose Responsive here to generate it.
What is the difference between auto-fit and auto-fill?
Both create as many columns as fit. With auto-fill the empty columns are kept, so a few items stay small. With auto-fit the empty columns collapse to nothing, so the items stretch to fill the row. This tool uses auto-fit.
In what order is the gap value written?
gap takes the row gap first and the column gap second. gap: 8px 24px means 8 pixels between rows and 24 pixels between columns. One value sets both.
When should I use grid instead of flexbox?
Use grid when you need to control rows and columns together, such as a gallery or a page layout. Use flexbox for a single row or column of items that should size themselves along one direction.
Is anything uploaded?
No. The CSS and HTML are built in your browser from the options you pick, and nothing is sent anywhere.