Nodes/ComfyUI/Batch Masks
ComfyUI Node Runs on cloud

Batch Masks

Stack a pile of masks into one tensor and get a free batch

By Comfy-Org·Created 4 years ago·Updated about an hour ago· 129,865
Batch Masks
  • masks
  • MASK

Batch Masks takes several separate masks and stacks them into a single batched mask tensor - one output where the batch dimension is "one slice per input mask." It's the mask version of the batch-image and batch-latent nodes that newer ComfyUI core ships, and it exists for one reason: batch everything and the sampler will process it in one pass instead of N.

Why you'll reach for it

Masks in ComfyUI are [B,H,W] tensors, and B can be more than 1. A single batched mask can carry a whole collection of regions - one per frame of a video, one per face in a group shot, one per variant you want to test. But separate masks coming out of separate nodes arrive as individual tensors, each with its own batch dimension of 1. Batch Masks is the merge that turns "a bunch of masks" into "one mask with a batch."

The payoff is the classic ComfyUI efficiency move: instead of running an inpainting pass once per mask, you batch the masks, run the sampler once, and get one result per slice. The same trick that lets you generate four prompt variants in one pass lets you regenerate four separate regions in one pass. For per-frame video masks - one mask per frame, batched, then composited back - it's basically the only ergonomic way to work.

How it works

The node takes an autogrowing set of mask inputs - connect one and a second slot appears, up to 50. In the background it does two things. First, every mask is resized to match the first mask's dimensions (bilinear). Then they're all concatenated along the batch dimension. That resize step is the hidden behavior to remember: Batch Masks silently normalizes sizes so it can stack them, and the first mask wins.

One output, MASK, with batch size equal to the number of inputs.

The inputs and outputs

  • masks - the autogrow inputs (mask_1, mask_2, ...). Minimum 1, maximum 50. Just keep connecting.

One output, MASK.

Getting it

Ships with ComfyUI core, nothing to install. It's one of the newer additions - the batch-image/mask/latent family landed in comfy_extras/nodes_post_processing.py during the 2026 batch-node push, so it won't show up in older installs. If you don't see it, update ComfyUI.

Where people get burned

  • The first mask dictates size. Feed it a 512x512 mask and a 1024x1024 mask and everything silently squashes to 512x512. If your composited result is the wrong resolution, this is why - check which mask is connected first, or resize before batching.
  • Sizes change meaning. The resize is bilinear, so a batched mask isn't pixel-identical to the originals if they differed in size. For region work that's usually fine; for pixel-exact compositing, normalize sizes upstream.
  • It's a stack, not a combine. Batch Masks is the wrong node if you want one region merging with another - that's MaskComposite (Combine Masks). Batch keeps the masks separate, just packed into one tensor. The distinction trips up everyone once.
Categoryimage/mask

Inputs (1)

NameTypeDefaultDescription
masksCOMFY_AUTOGROW_V3

Outputs (1)

NameTypeDescription
MASKMASK