Free visual CSS tool

CSS Masonry Layout Generator

Build a Pinterest-style masonry grid using the widely-supported CSS columns technique. Tune columns, gap, radius and shadow, then copy clean HTML and CSS.

Ready-to-use HTML + CSS

Real packing, no JavaScript

Ten variable-height cards show exactly how the columns technique packs content.

Two column modes

Fix an exact column count, or let column-width decide how many columns fit.

No layout library

Pure CSS columns — no JavaScript required to compute item positions.

Copy clean code

Get a ready-to-use masonry container and item markup with matching CSS.

How to build your masonry grid

  1. Pick a column modeChoose a fixed column count or a minimum column width.
  2. Tune spacingAdjust gap, corner radius and whether cards get a shadow.
  3. Copy the codeGrab the HTML and CSS and swap the placeholder cards for real content.

About the CSS columns masonry technique

This generator builds masonry using CSS multi-column layout — the columns or column-width property applied to a container, with each child item given break-inside:avoid so it never splits across columns. Items flow down one column top-to-bottom before continuing in the next column, which is what creates the packed, uneven-height Pinterest look with zero JavaScript. It's worth knowing this reading order differs from grid-based masonry: content fills column-by-column (down, then across) rather than row-by-row (across, then down), which matters if item order carries meaning. A newer native option, grid-template-rows: masonry, is being standardized in CSS Grid Level 3, but it isn't broadly supported across browsers yet, so the columns technique remains the practical, widely-compatible choice today.

column-count vs. column-width

Fix an exact number of columns, or let the browser compute the count from a minimum width — useful for fully responsive grids.

break-inside: avoid

This one declaration is what stops a card from being sliced in half between two columns.

Column-first reading order

Because items fill top-to-bottom per column, the visual order can look shuffled compared to a JS-computed masonry grid.

grid-template-rows: masonry

A newer CSS Grid masonry mode exists in the spec but isn't broadly supported yet, so it's not used here.

CSS masonry layout generator FAQ

How does this masonry layout actually work?

It uses the CSS multi-column technique (the columns property), where items flow down each column and wrap to the next, producing the classic Pinterest-style packed look without JavaScript.

Is there a newer native CSS masonry feature?

Yes, grid-template-rows: masonry is being standardized, but it isn't broadly supported across browsers yet, so the widely-compatible columns technique is used here.

Can I control column width instead of column count?

Yes. Switch the mode toggle to min-width, and columns will be generated automatically using CSS column-width based on your chosen minimum.

Does the masonry order read top-to-bottom or left-to-right?

With CSS columns, items fill one column top-to-bottom before moving to the next column, which differs from grid-based masonry libraries that fill left-to-right. This is called out in the about section below.

Try other layout tools

Keep building photo and grid layouts with these free tools.