CSS Flexbox Generator
Arrange flex items visually and copy CSS for alignment, wrapping and spacing.
Get a useful result from CSS Flexbox Generator.
Build a row of cards, a centered panel or a wrapping toolbar without guessing which flex property to change. Adjust the controls and compare the live arrangement before copying the CSS.
When this tool helps
- Choose direction before alignment
- See what wrapping and gap actually do
- Test exported CSS with real content
Choose direction before alignment
In row mode the main axis runs horizontally; in column mode it runs vertically. Justify-content works on the main axis, while align-items controls the cross axis. Reverse directions change visual flow, so check whether your reading and keyboard order still make sense.
See what wrapping and gap actually do
Add enough items to exceed the available width and compare nowrap with wrap. The preview allows scrolling rather than shrinking every item to nothing. A gap adds space between items, not around the outside of the container; use padding for that edge.
Test exported CSS with real content
Copy the container rule into your project and apply the container class. The preview items have demonstration widths, which are not included as design decisions in the exported rule. Long labels, images and different item widths can change wrapping.
Example input
4 items, row, center, wrap, 16px gapExpected output
display: flex; justify-content: center; flex-wrap: wrap; gap: 16px;Illustrative settings; actual output follows your chosen controls and browser.
Questions about this task
Does this generate HTML?
This tool exports a flex container CSS rule. Use your own semantic HTML, or create starter markup with HTML Code Generator.
Why does justify-content change in column mode?
The main axis follows flex-direction. Column mode uses the vertical axis for justification.
Is the preview a device emulator?
No. It uses the available browser space. Test the final page at real viewport widths and with your content.
How to use CSS Flexbox Generator
Add items, choose direction and alignment, adjust gap and wrapping, then copy or download the generated CSS.
Good to know
Preview uses your browser’s CSS implementation. Up to 20 items and a 100px gap. Check the exported layout with your real content and target browsers.
A few helpful answers
Is this tool free?
Yes. All features on this page are free and require no account.
Where is my data processed?
In your browser. Tool input and selected images are not sent to our servers. Clear the page or close the tab to discard your input.
What should I check before using the result?
Preview uses your browser’s CSS implementation. Up to 20 items and a 100px gap. Check the exported layout with your real content and target browsers.
