Nodes/ComfyUI Impact Pack/Mask Batch to Mask List
ComfyUI Node Runs on cloud

Mask Batch to Mask List

Split a stack of masks so nodes iterate one at a time

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
Mask Batch to Mask List
  • masks
  • MASK

Mask Batch to Mask List converts a batch of masks into a list of masks. That sounds like a distinction without a difference until you hit it, and then it's the exact node you were missing. In ComfyUI a "batch" is one tensor holding many masks stacked together, processed as a unit; a "list" is many separate items that downstream nodes process one at a time. Some nodes want one, some want the other, and this node crosses from batch to list.

Here's when it bites. You've got, say, five masks bundled as a batch - maybe from a detector, maybe from a multi-mask operation - and you feed them into a node expecting to handle each mask individually. Instead of running five times, it treats the whole batch as one blob, or errors, or only touches the first. The fix is to convert the batch into a list, at which point ComfyUI's list handling kicks in and the downstream node runs once per mask automatically. This node is that converter.

How it works

ComfyUI has two ways to carry multiple things through a graph. A batch is a single tensor with a batch dimension - efficient, moves as one object, and nodes that understand batches process the whole thing together. A list is the graph-level construct where a socket carries N separate values, and ComfyUI re-runs the receiving node once for each. This node takes the batched mask tensor and unpacks it along the batch dimension into a list of individual masks. Nothing about the masks changes - same pixels - only the container they travel in. Its exact inverse is Mask List to Masks, which packs a list back into a batch.

The inputs and outputs that matter

Refreshingly minimal:

  • masks (optional) - the batch of masks to split. It's marked optional so the node degrades gracefully with nothing connected, but in practice you always wire your batch here.

Output:

  • MASK (a list) - the same masks, now as individual list items. Wire this into whatever needs to process one mask at a time, and that node will iterate over them for you.

There are no settings. It converts, that's all.

How to install it

Install the pack via ComfyUI Manager (search ComfyUI Impact Pack, install, restart), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
python -m pip install -r requirements.txt   # ComfyUI's python; python_embeded on portable

then restart. No models, no extra dependencies - it's a pure data-shape utility.

Common issues & troubleshooting

Downstream still only processed one mask. Then you probably didn't actually have a batch - you had a single mask. This node only splits what's already stacked; if your source produced one mask, you get a one-item list. Check upstream that multiple masks exist.

I converted to a list and now a later node is confused. Some nodes genuinely want a batch, not a list, and the two aren't interchangeable everywhere. If a node downstream expects batched masks, convert back with Mask List to Masks before it. The rule of thumb: use a list when you want per-item iteration, a batch when a node wants to handle everything at once.

Which do I even have? ComfyUI doesn't always make it obvious. If a node that should run per-mask runs once on everything, you have a batch and want this node. If a node throws a shape error about too many items, you may have a list where a batch belongs. This node and its inverse are how you flip between the two until the shapes line up.

CategoryImpactPack/Operation

Inputs (1)

NameTypeDefaultDescription
masksoptMASK

Outputs (1)

NameTypeDescription
MASKMASK