Mask List to Batch
When your masks come back as a list, this is the glue
- mask_list
- mask_batch
ComfyUI has two ways of handing you multiple masks, and they are not interchangeable. Some nodes give you a batch - one tensor shaped [B, H, W] - and some give you a list of individual mask tensors. The list is the annoying one, because a chunk of the ecosystem wants a batch and will just sit there refusing to connect. Mask List to Batch is the adapter that turns a pile of individual masks back into one stacked batch.
When you'd reach for it
You'll hit this right after anything that breaks a mask apart per-object. The pack's own Mask Separate node outputs one mask per detected region (a list), and per-item steps like masking each region in its own branch also leave you with a list. Downstream, a MASK batch is what Save Mask, inpainting, and most batch-processing nodes expect. That's your classic "two systems, one missing bridge" moment.
How it works
Under the hood it's simple and honest: if the input is already a single tensor, it passes through untouched. If it's a real list, the node finds the tallest and widest mask, zero-pads every other mask to that size on the right and bottom, then concatenates them on the batch dimension. Padding with 0 is the right call for masks - zero means "outside," so a padded mask doesn't gain phantom coverage.
Two edge cases worth knowing because they'll trip you up exactly once each. An empty list returns an empty [0, 64, 64] tensor instead of erroring, which is great if you want to branch on "no regions found" but will confuse you if you feed it somewhere that expects real frames. And a single-element list returns that one mask as-is, no reshape drama.
The inputs that matter
There's really one:
- mask_list (
MASK) - the list of masks to stack. It's flagged as a list input, so the wire knows what it's getting.
And one output:
- mask_batch (
MASK) - the combined batch, ready for whatever batch node comes next.
Nothing else to configure, which is refreshing.
Installing it
Same as the rest of the pack. Easiest route is ComfyUI Manager → search ComfyUI-1hewNodes → install → restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Then restart ComfyUI. This node needs no model downloads - it's pure tensor math. One pack-level gotcha: the pack's requirements.txt is heavy (opencv, scikit-image, and for the detection nodes rembg, ultralytics, transformers, the works), and Manager installs all of it even if you only use the utility nodes. Also, this pack is built on ComfyUI's newer comfy_api.latest API - if nodes don't appear after install, update ComfyUI itself first.
Common issues
The main trap is spatial: zero-padding only aligns the batch's corner, so if two masks in the list came from different-sized canvases, their content won't line up pixel-for-pixel after stacking. If you need exact alignment, get your masks onto a common canvas before the list - don't rely on this node to reconcile geometry. And remember the empty-list behavior above: a [0, 64, 64] output is a feature for conditional workflows, not a bug.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_list | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask_batch | MASK | — |