iLoveDocsTools
All ToolsCSS Grid Generator

CSS Grid Generator

Visually build CSS Grid layouts. Stack elements inside cells, reorder them, then copy the complete CSS and HTML.

?

FREE

Loading…

Go Pro ↑

Grid Controls

Columns3
Rows3
Col Gap16px
Row Gap16px

Column Sizes

C1
C2
C3

Row Sizes

R1
R2
R3

Visual Grid (click cell to edit)

+
+
+
+
+
+
+
+
+
.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  column-gap: 16px;
  row-gap: 16px;
}




/* ── Responsive ────────────────────── */
@media (max-width: 1024px) {
  .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .grid-container {
    grid-template-columns: 1fr;
  }
}
Your files never leave your device. All processing happens locally in your browser — nothing is uploaded to our servers.Files are never stored on our servers · No tracking of your file contentsPrivacy Policy

What is CSS Grid Generator?

CSS Grid Generator is a free online visual builder for CSS Grid layouts. Set the number of columns and rows, control the size of each track independently, adjust column and row gaps, and click any cell to define a named grid area and fill it with stacked elements — headings, paragraphs, buttons, links, images, and dividers — reordered with simple up/down controls. Copy complete, production-ready CSS and matching HTML markup instantly, with live desktop, tablet, and mobile preview built in.

CSS Grid and Flexbox solve related but distinct layout problems, and knowing which to reach for saves a lot of fighting with the wrong tool. Flexbox is fundamentally one-dimensional — it excels at distributing items along a single row or column, which is why it's the right choice for a navbar, a button group, or a list of tags. Grid is two-dimensional by design: it lets you define both rows and columns simultaneously and place content into specific cells or named regions, which is exactly what you need for a full page layout with a header, sidebar, main content area, and footer, or for a card gallery that needs to align items across both axes at once.

The fr (fractional) unit is central to how this tool sizes columns and rows, and it behaves differently from a plain percentage. A track defined as 1fr claims one "share" of whatever space remains after fixed-size tracks (like 200px or auto columns) have taken their portion — so grid-template-columns: 1fr 2fr splits the remaining space into thirds, with the second column getting two of them. This makes proportional layouts trivial to express without doing percentage math by hand, and it's why fr is the default unit this tool reaches for.

Named grid areas — set by typing a name into any cell's Area Name field — compile down to the grid-template-areas CSS property, which lays out your grid visually as a small ASCII grid of names directly in your stylesheet. This is one of the most readable parts of the entire CSS Grid specification: a two-row layout with a full-width header, a sidebar, and a main content area reads almost like a diagram in the generated CSS, which is far easier to reason about six months later than a layout built purely from numeric column and row indices.

Every layout also needs to degrade gracefully on smaller screens, so the generated CSS includes tablet and mobile breakpoints automatically — collapsing to a two-column layout under 1024px and a single column under 640px, with named grid areas suspended at those breakpoints so content simply stacks in source order rather than fighting a grid definition that no longer makes sense at that width. Everything — the visual editing, the live preview, and the code generation — runs in your browser with no account or server round-trip required.

How It Works

Each grid cell is tracked independently and can hold an ordered list of content elements — headings, paragraphs, buttons, links, images, or dividers. Clicking a cell opens its properties panel, where adding an element appends it to that cell's list; the ↑↓ controls swap adjacent array entries to reorder them, and edits to text, image URLs, or link targets update the underlying data immediately. The CSS output is assembled from three pieces: a .grid-container rule holding grid-template-columns, grid-template-rows, column-gap, row-gap, and — if any cell has been given a name — a grid-template-areas block built by mapping every named cell onto its row/column position; a per-cell class for every configured cell carrying its background color, text color, border radius, box shadow, padding, and flex-based internal alignment; and a responsive section with @media rules that collapse the column definition at 1024px and 640px breakpoints. The HTML output mirrors the same structure, rendering one <div> per grid cell with the appropriate class and its stacked child elements — headings as <h2>, paragraphs as <p>, buttons as <button>, links as <a>, images as <img>, and dividers as <hr> — in the exact order you arranged them.

How to Use

  1. 1

    Set columns and rows

    Use sliders to define how many columns and rows your grid has.

  2. 2

    Click a cell

    Click any cell in the visual grid to open the Cell Properties panel.

  3. 3

    Add elements

    Click any element type button to append it to the cell.

  4. 4

    Reorder elements

    Use ↑↓ arrows to change element order within the cell.

  5. 5

    Copy CSS or HTML

    Switch tabs in the code panel and copy whichever output you need.

Who Uses This Tool

📰

Page Layouts

Build header/sidebar/main/footer layouts with named grid areas.

🃏

Card Grids

Create responsive product or blog card grids with custom colors and shadows.

📊

Dashboards

Arrange widgets in multi-column grid layouts with visual editing.

🖼️

Image Galleries

Design variable-span image galleries with custom border radius.

📱

Responsive Design

Use fr units and auto-fill for layouts that adapt without media queries.

🗺️

Complex Forms

Arrange form fields in structured grid areas with visual alignment.

Why Choose This Tool

Multi-Element Cells

Stack headings, paragraphs, buttons, links, and images inside each cell.

Drag-to-Reorder

Reorder elements inside a cell with ↑↓ arrows — no code editing needed.

CSS + HTML Output

Copy the grid CSS and the matching HTML markup separately.

fr Unit Support

Fractional units by default for flexible proportional columns.

Instant Live Preview

Grid updates in real time as you change any property.

Beginner Friendly

Visual interaction makes CSS Grid accessible for all skill levels.

Key Benefits

  • Visual grid builder with named grid-template-areas support
  • Multi-element cells: stack headings, paragraphs, buttons, links, images, dividers
  • Reorder elements within a cell using ↑↓ controls — no code editing
  • Independent column and row track sizing with fr, px, auto, and minmax()
  • Copy both CSS and matching HTML output separately
  • Responsive breakpoints for tablet and mobile generated automatically

Frequently Asked Questions

Also Known As

css grid generator online freevisual css grid layout buildercss grid template generatorgrid layout generator css toolcss grid area generatoronline css grid builder freecss grid code generatorcss grid fr unit generator

Trusted Worldwide

Free Online Document Tools for Everyone

iLoveDocsTools is used by students, professionals, and businesses across the United States, Canada, United Kingdom, Australia, India, and more than 100 other countries. All tools are browser-based and process files privately — your files never leave your device. Free to use, with Pro plans for unlimited access.

No Upload Required

All processing happens directly in your browser. Your documents are never sent to any server — complete privacy guaranteed for users in the USA, Canada, UK, and worldwide.

Free to Use — Pro Plans Available

Every tool on iLoveDocsTools is free to use. Need more? Upgrade to Pro for unlimited usage, priority access, and no daily limits. Trusted by students, freelancers, and teams across North America and Europe.

Works on Any Device

Whether you are on a Mac, Windows PC, iPhone, or Android in New York, Toronto, London, or Sydney — our tools work instantly in any modern browser.

Looking for free PDF tools in the USA? Free document converters in Canada? Online PDF editors in the UK or Australia? iLoveDocsTools offers 70+ free tools — merge PDF, split PDF, compress PDF, convert Word to PDF, Excel to PDF, JPG to PDF, and many more — all free, all instant, all private. No watermarks. No file size limits. Just free tools that work.