ComfyUI Node

Image Grid

Turn a whole batch of images into one tidy grid, no extra node pack required

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Image Grid
  • images
  • IMAGE

You've just run a batch of seeds through the sampler and you've got 16 images sitting on the wire. Now you want to eyeball them all at once instead of paging through a gallery one at a time. That's the entire job of XJImageGrid: it takes an IMAGE batch, arranges every frame into a rectangle of rows and columns, and hands you back a single image of the whole grid.

It's a one-input, one-output utility that lives in the ComfyUI-XJNodes pack. The pack is one developer's personal grab-bag (more on that below), and this is one of its simplest and most genuinely useful nodes - there's no clever UI, no settings, no hidden state. You just drop it between anything that outputs a batch and anything that saves or previews an image.

How it works

The mechanism is refreshingly dumb. ComfyUI's IMAGE tensors are batches shaped (N, height, width, channels), so the node reads N from the batch size and figures out the grid geometry itself: rows and columns are both chosen from the square root of the batch size, so 9 images becomes a 3×3, 16 becomes 4×4, 7 becomes an uneven 2×4. Each frame is pasted onto a white canvas at its natural position, and the assembled canvas comes back out as a normal IMAGE you can wire straight into a Save Image or Preview node.

Two things worth knowing:

  • The output is one combined image, not a batch. If you feed it to Save Image, you get a single file of the whole grid - which is usually exactly what you want for a contact sheet.
  • Everything must be the same resolution to start with. That's normally true when a KSampler emitted the batch, but if you're feeding in mixed-size images from a directory loader, size them up first or the paste will misbehave. XJLoadImagesFromDirBatch (same pack) normalizes its output for you, so the two pair nicely.

The inputs and outputs

The input side is the whole story:

  • images (IMAGE) - the batch to grid up. Nothing else. There are no optional inputs and no knobs to miss.

Output is a single IMAGE of the assembled grid. It's not an output node, so you still need a Save or Preview node downstream to actually look at it.

Installing it

XJImageGrid ships in ComfyUI-XJNodes, so you install the pack once and get all of its nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes

then restart ComfyUI. ComfyUI Manager users can skip the terminal: search for ComfyUI-XJNodes in the manager and install it there. There are no model downloads and requirements.txt is empty - the pack leans entirely on Pillow and torch, which ComfyUI already bundles.

Common issues

Honestly, there's not much that can go wrong here. The main trap is feeding it a batch of mixed sizes, which produces an output where frames don't line up or get clipped. The pack is also a personal project with a small footprint - the README says it's "primarily for personal use and experimentation," and you won't find a community or a pile of tutorials behind it. That's fine for a node this trivial: if the grid logic ever surprises you, the whole class is about sixty lines in nodes/image/batch.py, readable in five minutes.

CategoryXJNodes/image

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE