Nodes/ComfyUI Essentials/πŸ”§ Mask Batch
ComfyUI Node Runs on cloud

πŸ”§ Mask Batch

Stack two masks into one batch

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,152
πŸ”§ Mask Batch
  • mask1
  • mask2
  • MASK

Mask Batch is the mask equivalent of an image-batch node - it combines mask1 and mask2 into a single batched MASK, so anything downstream that expects one batch instead of two separate wires actually gets one. Think a detailer node processing multiple regions in sequence, or any loop-style node that walks a batch item by item.

The situation it solves is common enough to be annoying without it: you've built two masks in two different branches of your graph - say, one from Mask From Color keying a background and one from Mask From Segmentation isolating a subject - and the node you want to feed them to only accepts a single MASK input that it treats as a batch. Rather than hand-rolling a concatenation, this is the one-node fix. It's also the natural pairing with Mask Expand Batch elsewhere in this pack: batch two masks together here, then pad the result out to a target count there if you need a specific frame count downstream.

How it works

It's a straightforward concatenation along the batch dimension - no blending, no merging the two masks into one combined shape. It just stacks them so both travel together on a single output wire.

Inputs and outputs

mask1, mask2. Output: MASK.

Installing it

Via ComfyUI Manager, search "ComfyUI Essentials". Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/ComfyUI_essentials

Restart. Maintenance-only pack since April 2025.

Common issues & troubleshooting

Wanted a combined region (union or intersection), got two masks traveling together instead. That's the most common confusion with this node - it stacks, it doesn't merge. If what you actually want is one mask that's the union of two regions ("everywhere covered by either mask") or their intersection, that's a different operation entirely, and whatever consumes a MaskBatch output that you meant as a union will likely only look at the first mask or process the two independently, not combine them.

Shape mismatch error. mask1 and mask2 need matching resolutions before you batch them - this node assumes they already line up and doesn't resize either one for you. Fix the mismatch upstream first.

Order matters more than expected downstream. Some nodes that consume a mask batch process items in order - if you're seeing mask1's region acted on before mask2's when you expected the reverse, check whether the consuming node cares about batch order and swap your inputs if it does.

Need more than two masks batched together. This node only takes two inputs at a time - for three or more, chain another Mask Batch off the output of the first one, feeding its MASK output in as mask1 of the next, and so on. There's no single node in this pack for an arbitrary N-way batch.

Categoryessentials/mask batch

Inputs (2)

NameTypeDefaultDescription
mask1MASKβ€”
mask2MASKβ€”

Outputs (1)

NameTypeDescription
MASKMASKβ€”