Nodes/Tojioo Passthrough/Any Mask Batch Switch
ComfyUI Node

Any Mask Batch Switch

Combine masks into one batch for batch inpainting

By Tojioo·Created 12 months ago·Updated 19 days ago· 13
Any Mask Batch Switch
  • mask_1
  • masks

Any Mask Batch Switch merges several MASK inputs into a single mask batch and sends it to the masks output. One mask wired in, and it passes through unchanged; several wired in, and they're stacked into a batch that a single inpainting or composition path can consume at once. It's the "combine into a batch" sibling of the pack's single-select mask switch - and honestly, the batch version is the one people tend to need.

Think about how masks actually arrive in ComfyUI: one from a segmenter, one from a manual paint, one from a detection pass. Individually they're useless to a node that wants a mask batch for a whole region set. This node is the merge point.

How it works

Starts with mask_1 and grows a slot per additional mask source. A single connected input passes through as-is. With several, each mask is prepared (a 2D single mask gets a batch dimension) and concatenated along the batch axis - but only within the largest group of matching shapes. The catch is the same one as the image batch switch: masks of different resolutions aren't concatenated, they're dropped. The node takes the biggest same-size group and silently ignores the rest.

Where you'd use it

  • Multiple segmentation masks into one batch for region-wise inpainting.
  • Manual + automatic masks combined for a composite pass.
  • Batch masking downstream where the consumer wants a stack, not a single mask.

Install

ComfyUI Manager → search "Tojioo Passthrough" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Tojioo/tojioo_passthrough.git

Restart ComfyUI. No models or pip dependencies - the pack is lean Python plus a bundled frontend, on the Comfy Registry under publisher tojioo.

Common issues

Resolution mismatch is the quiet killer here: feed it masks at different sizes and the node batches the largest matching group and drops the rest, with no error to tell you. If a batch comes back short, check every mask is the same resolution (or resize them upstream). One more thing to know: this merges masks into a batch - it doesn't union them into a single mask. If you want one combined mask region instead of a batch, use a Mask Composite-style node, not this one.

CategoryTojioo Passthrough/Dynamic Nodes/Batch Switch Nodes

Inputs (1)

NameTypeDefaultDescription
mask_1optMASK—

Outputs (1)

NameTypeDescription
masksMASK—