CSS Grid & Flexbox Generator
Switch between Grid and Flexbox, adjust the layout properties, and watch the preview update live — then copy the generated CSS straight into your project.
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 12px;
}Your files are processed locally in your browser. They are not uploaded to our servers.
How to use
- Choose Grid or Flexbox mode.
- Adjust the layout controls — columns and rows for Grid, or direction, wrap and alignment for Flexbox.
- Copy the generated CSS shown below the live preview.
What is this tool?
CSS Grid & Flexbox Generator is a visual tool for building CSS layout code without memorizing property names or values. Adjust the controls and see both a live preview and the exact CSS needed to reproduce it, ready to paste into a stylesheet.
Common uses
- Prototyping a grid or flex layout before writing code by hand
- Learning how CSS Grid and Flexbox properties affect layout
- Quickly generating boilerplate CSS for a new component
- Experimenting with alignment and spacing options visually
Related tools
FAQ
What's the difference between Grid and Flexbox?
Flexbox is designed for one-dimensional layouts (a single row or column), while Grid handles two-dimensional layouts (rows and columns together). Use Flexbox for simple alignment tasks and Grid for more complex page or component layouts.
Does the generated CSS work in all browsers?
Yes. Both CSS Grid and Flexbox are supported in all modern browsers, so the generated code works without additional vendor prefixes or fallbacks.
Can I use this for a full page layout?
Yes, though for full-page layouts you'll typically want to combine this generated container CSS with your own responsive breakpoints and content-specific styling.