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

πŸ”§ Mask From Batch

The mask slicer ComfyUI core forgot

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,152
πŸ”§ Mask From Batch
  • mask
  • MASK
β—„start0β–Ί
β—„length1β–Ί

If you've ever tried to grab a slice out of a batch of images in ComfyUI, you've probably reached for the core Image From Batch node without a second thought. Try to do the same thing with a batch of masks, though, and there's nothing there. That's exactly the gap ComfyUI Essentials exists to fill - the pack's own tagline is "essential nodes that are weirdly missing from ComfyUI core" - and MaskFromBatch is about as literal an example of that mission as you'll find.

What it does

You give it a batch of masks - say, per-frame masks out of a video segmentation node, SAM tracking output across a clip, or just a batch mask you generated alongside a batch of images - and it hands back a sub-slice of that batch. Nothing fancier than that. It's list slicing for masks: pick a starting index, pick how many to take, done.

This matters more than it sounds like once you're doing anything with video or batched generation. You rarely want the whole mask batch downstream - you want frames 5 through 20 for a specific transition, or you want to drop the first couple of frames because your source video had a bad lead-in. Without this node your only options are re-running the upstream process with different parameters or fighting with reroutes and list math. With it, you just wire in start and length.

The inputs and outputs that matter

There are exactly three inputs, and they're all you need:

  • mask (MASK) - the batch you're slicing from.
  • start (INT, default 0) - the index to begin at.
  • length (INT, default 1) - how many masks to take from that point.

The output is a single MASK - your sliced sub-batch, ready to wire into whatever consumes masks next: a compositing node, a VAE encode for inpainting, a save node, or another essentials node further down the graph.

If you're pairing this with an image batch (which is the common case - think "I sliced the video frames, now I need the matching masks"), keep start and length identical on both nodes. It's on you to keep them in sync; the node has no idea an image batch exists.

How to install it

Two paths, same as any ComfyUI Essentials node:

  • ComfyUI Manager - open the manager, search "ComfyUI Essentials," install, restart ComfyUI.
  • Manual git clone:
cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/ComfyUI_essentials

Restart ComfyUI afterward either way. The pack is by cubiq (Matteo Spinelli), the same author behind ComfyUI_IPAdapter_plus - one of the most widely used node packs in the whole ecosystem - so the code quality and update discipline here are a known quantity, even with the pack currently in maintenance-only mode (more on that below).

Common issues

"Nothing happens" / mask looks empty. Check that start isn't past the end of your batch - if your mask batch has 16 frames and you set start to 20, you'll get nothing usable back. length similarly can't pull frames that don't exist past the batch boundary.

Output batch doesn't match your image batch. This is the most common real mistake: people slice the mask batch with one start/length pair and the image batch with another (or don't slice the image batch at all). They have to match, or downstream compositing will pair the wrong mask with the wrong frame.

The pack is in maintenance-only mode. As of April 2025, cubiq's own README says he no longer uses ComfyUI as his primary tool and isn't doing ongoing work here - he'll still consider "crucial" PRs, but don't expect active development. MaskFromBatch is about as simple and stable a node as exists in the pack, though, so this is a low-risk one to depend on even in that state.

Categoryessentials/mask batch

Inputs (3)

NameTypeDefaultDescription
maskMASKβ€”
startINT0β€”
lengthINT1β€”

Outputs (1)

NameTypeDescription
MASKMASKβ€”