Home › Developer Tools › CSS Grid Generator

CSS Grid Generator

Design a CSS grid visually: set column and row sizes, drag across cells to create named areas and copy ready-to-use grid-template CSS and HTML. Everything happens in your browser.

Last updated:

Presets

Drag across cells to create a named area (tap a single cell for a 1×1 area).

Tracks

Columns
Rows

Named areas

    Add an area by row and column
    CSS
    
          
    HTML
    
          
    Advertisement

    How to use the CSS Grid Generator

    1. Start from a preset or the blank 3×3 grid.
    2. Set the tracks: type a size for each column and row (for example 200px, 1fr or minmax(100px, 1fr)) and use + Column / + Row to add more.
    3. Drag across cells in the preview to create a named area, then rename it in the Named areas list.
    4. Adjust the gaps and, if needed, a min-height such as 100vh. Tick Stack areas on mobile for a responsive layout.
    5. Press Copy CSS and Copy HTML and paste them into your project.

    CSS grid track sizes explained

    Track sizeMeaningTypical use
    200pxFixed sizeSidebars, icon columns
    25%Percentage of the containerRarely needed; fr is usually better because it accounts for gaps
    1frOne share of the free space (min. content size)Main content, equal columns
    autoSized to contentHeader and footer rows
    min-contentAs narrow as the longest word or widest itemTight label columns
    max-contentAs wide as the content without wrappingColumns that must not wrap
    minmax(200px, 1fr)At least 200px, grows to one shareFlexible columns with a minimum
    fit-content(300px)Content size, but no wider than 300pxSidebars that adapt to their content

    Worked example: how fr is calculated

    A container is 1000px wide with grid-template-columns: 200px 1fr 2fr and column-gap: 20px. Two gaps take 40px and the fixed column takes 200px, leaving 1000 − 200 − 40 = 760px of free space. That is split into 1 + 2 = 3 shares of about 253.3px, so the second column is 253.3px wide and the third 506.7px. If the container shrinks to 700px, the shares become (700 − 240) ÷ 3 ≈ 153.3px, while the first column stays at 200px.

    Template areas rules and tips

    • One string per row, one token per column. Every row string must have the same number of cells as there are columns.
    • Rectangles only. Each name must cover a single rectangle; the tool enforces this by only letting you drag rectangles and blocking overlaps.
    • Dots are empty cells. A . (or several dots like ...) marks a cell that no named area uses.
    • Names are identifiers. Use letters, digits, hyphens and underscores, and do not start with a digit.
    • Source order still matters. Areas change where things appear, not the reading order for screen readers. Keep your HTML in a logical order (header, nav, main, aside, footer).
    • Line numbers are an alternative. grid-area: 1 / 1 / 2 / 4 means row-start / column-start / row-end / column-end, with lines counted from 1.

    For one-dimensional rows of items inside an area, combine grid with flexbox. When you are done, tidy the output with the CSS Formatter and HTML Formatter.

    Frequently asked questions

    What does the fr unit mean in CSS grid?

    fr is a fraction of the free space in the grid container. With grid-template-columns: 1fr 2fr, the remaining width (after fixed tracks and gaps) is split into 3 parts: the first column gets one part and the second gets two.

    How does grid-template-areas work?

    You write one quoted string per row, with one name per column. Repeating a name across neighbouring cells makes that area span them, and a dot (.) leaves a cell empty. Each child then gets grid-area: name. Every named area must form a single rectangle.

    Why can't my areas be L-shaped or overlap?

    The CSS specification only allows rectangular named areas in grid-template-areas; an L-shape or a gap in a name makes the whole declaration invalid. Items placed by line numbers can overlap, but named areas from the template cannot.

    What is the difference between 1fr and minmax(0, 1fr)?

    1fr really means minmax(auto, 1fr), so a column will not shrink below its content's minimum width, which can cause overflow with long words or wide images. minmax(0, 1fr) lets the column shrink fully, keeping columns truly equal.

    What does auto mean for a row or column?

    An auto track sizes to its content, between the content's minimum and maximum size. It is ideal for headers and footers. In this tool's preview, empty auto tracks are given a 40px minimum so you can still see and select them.

    How do I make a CSS grid responsive?

    Use a media query that changes grid-template-columns and grid-template-areas on small screens, often to a single column. Tick Stack areas on mobile to have that media query generated, ordered top to bottom and left to right. For card grids, repeat(auto-fill, minmax(200px, 1fr)) is another common pattern.

    Should I use grid or flexbox?

    Use grid when you lay out both rows and columns at once, such as page templates and dashboards. Use flexbox for content that flows in one direction, such as navigation bars, toolbars and button groups. They work well together: a grid area can be a flex container.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    CSS FormatterBeautify CSS with indent controls and optional property sorting.HTML FormatterBeautify and indent HTML code with a live preview.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Tooltip GeneratorBuild pure CSS tooltips: position, arrow, colors, padding and animation. Copy HTML and CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.
    See all 52 Web, HTML & CSS Tools →