Skip to content

Flexbox generator

Set the flex container properties and watch the items rearrange live. Click any item to change its own settings, then copy the code as CSS or Tailwind classes.

  • Free, no limits
  • No sign-up
Everything happens in your browser; your data is never uploaded.
● Requests carrying your input: none · site files: 0 · analytics (no content): 0
Why is there no “save online” button?

Because server-side “save and share” keeps leaking. In November 2025, watchTowr researchers collected thousands of publicly reachable saved entries from two popular online formatters (jsonformatter.org and codebeautify.org), including passwords, API keys, tokens, and banking and government data. Here, everything runs in your browser; a shared link carries the data after the #, which browsers never send to the server. watchTowr Labs

  • ✓ Free
  • ✓ No sign-up
  • ✓ Nothing uploaded

Next step

What to do next

How to use it

  1. Pick a preset (perfect centering, navbar, card grid, sidebar, sticky footer), or start from the defaults.
  2. Set flex-direction, flex-wrap, justify-content, align-items and gap.
  3. Click an item and set its flex-grow, flex-shrink, flex-basis, order and align-self.
  4. Drag the box's corner to test other widths, then copy the code.
Try it now

The two axes

Flexbox lays things out along a main axis: horizontal by default (row), vertical for column.

  • justify-content distributes items along the main axis (start, center, end, even spacing).
  • align-items aligns them on the cross axis (top, center, bottom, stretch).
  • align-content only matters when wrapping (flex-wrap: wrap): it aligns the lines against each other.

The classic mix-up: in a column, the two swap roles, so justify-content aligns vertically.

grow, shrink and basis in brief

PropertyWhat it doesTypical value
flex-growhow much of the leftover space it takes1 for a “fill” item
flex-shrinkhow much it may shrink0 for a sidebar
flex-basisstarting size before growing200px, 30%, auto

The card grid preset uses flex-wrap: wrap with flex: 1 1 140px: cards are at least 140px wide and fill each row. For a strict grid, the CSS grid generator is the better fit.

Tailwind output

Container classes (flex flex-col justify-between items-center gap-[12px]) and per-item classes (grow, shrink-0, basis-[140px], self-end) are listed on separate lines. Defaults are left out, so the code stays short.

Frequently asked questions

How do I center something with flexbox?

On the container: display: flex; justify-content: center; align-items: center. That's the “Perfect centering” preset.

What's the difference between justify-content and align-items?

justify-content works on the main axis, align-items on the cross axis.

Flexbox or grid?

Flexbox for one row or column, grid for two-dimensional layouts.

What does flex: 1 mean?

flex-grow: 1, flex-shrink: 1, flex-basis: 0%: the item shares space equally with its siblings.

Sources

Recommended

Similar tools

If Flexbox generator helped, you may need these too.

See all in category →

People also use