howtoUpdated 10/28/2026

Build a 2×2 or 3×3 product grid in ComfyUI, evenly spaced

A detail-page grid should be a template, not a manual alignment job. Learn a core-node layout that keeps every tile the same size with clean white gaps.

Build a 2×2 or 3×3 product grid in ComfyUI, evenly spaced
63-second overview: 2x2 and 3x3 product grids with even spacing

Spacing is where grids break

A detail-page overview looks simple: duplicate the product a few times and lay it out in a grid. The time goes into alignment — tile size, gaps, outer margin. If one value drifts, the whole sheet looks off.

Make it a template: one input product image, one fixed layout, repeatable every time.

Product input
Sample input: one transparent product shot

The 2×2 math

  • Tile 800×800
  • Gap 20 px
  • Outer margin 20 px
  • Canvas = 20 + 800 + 20 + 800 + 20 = 1660
  • Scale proportionally to 2000×2000

The four top-left corners are (20,20), (840,20), (20,840) and (840,840).

2×2 sheet
2×2: four 800 px tiles, 20 px gaps

The 3×3 math

  • Tile 520×520
  • Gap 20 px
  • Outer margin 20 px
  • Canvas = 20 + 520 + 20 + 520 + 20 + 520 + 20 = 1640
  • Also scaled to 2000×2000

The nine x/y positions are combinations of 20, 560 and 1100.

3×3 sheet
3×3: nine 520 px tiles, 20 px gaps

Node order

  1. 1LoadImage reads the product
  2. 2InvertMask recovers alpha
  3. 3MaskToImage turns it into a black-and-white image
  4. 4ResizeAndPadImage produces the 800 and 520 tile sizes with black padding
  5. 5ImageToMask recovers the scaled alpha
  6. 6ResizeAndPadImage scales the source image
  7. 7Composite one tile on an 800/520 white EmptyImage using alpha
  8. 8Composite that tile onto the 1660/1640 canvas using a full-tile white mask
  9. 9ResizeAndPadImage up to 2000
  10. 10SaveImage writes both sheets

Step 8 must use a full-tile white mask, not the product alpha. With the product alpha, the white background inside each tile is not copied and you get black blocks.

Using different angles

This version repeats one image, which works for an overview or a layout template. For multiple angles:

  • Add a LoadImage per view
  • Point the matching ImageCompositeMasked.source at it
  • Keep x/y, tile size and mask unchanged

Spacing and margins stay fixed; only the content changes.

Common issues

Black tile backgrounds? The tile was composited with the product alpha instead of a full-tile white mask. The black comes from the padding added by ResizeAndPadImage.

Uneven tile sizes? The 2×2 and 3×3 grids need their own ResizeAndPadImage sizes; they cannot share one.

Clipped edges? The source product touches the frame. Trim it to the product bounds first, or run the white-canvas workflow to add a safe margin before building the sheet.

Related workflows

Related guides

A grid belongs in the middle of a detail page, summarizing the selling points. Keep the main image as a single white-canvas shot so marketplace thumbnails do not squeeze four tiles into a tiny square. When you later add more angles, keep the same tile size and gap values; changing one grid without the other is the fastest way to make a detail page look inconsistent.

Workflows used in this guide

Check the version's test records and delivery status. Online trials are available only when enabled.

Keep reading