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

πŸ”§ Batch Count

Batch Count β€” how many items are in that batch? This node tells you.

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,152
πŸ”§ Batch Count
  • batch
  • INT

Deceptively handy little utility. Batch Count looks at whatever batch is flowing through a wire - a batch of images, of latents, whatever - and tells you how many items are in it, as an integer. That's the whole node. But "how big is this batch?" turns out to be a number you need surprisingly often once you start building anything dynamic.

What it does

One input, batch, typed as * (the wildcard, so it accepts any batched type). One output, an INT: the count. If four images come down the wire, it outputs 4. If your load-images node grabbed 37 frames from a folder, it outputs 37.

The reason it's a wildcard is that "batch" isn't one type in ComfyUI - images, latents, and other tensors all carry a batch dimension. Batch Count doesn't care what the items are, it just reports how many there are.

Why you'd want the count

Because a lot of downstream behavior should scale with the batch size instead of being hard-coded. A few real cases:

  • Driving a loop or an index. If you're stepping through a batch, you need to know where it ends.
  • Computing a grid layout. Laying out N images into a contact sheet? You need N to figure out rows and columns.
  • Sanity-checking a load. You pointed a loader at a folder and want to confirm it actually grabbed the number of frames you expected - feed the count to a Display Any and read it off the canvas.
  • Feeding math. Wire the count into the Simple Math nodes to compute things like "steps per image" or a total from a per-item cost.

It's a source of truth about the data actually moving through your graph at run time, rather than a number you typed and hope is still correct.

Installing it

Part of ComfyUI Essentials by cubiq - Matteo Spinelli, the developer behind the widely-used ComfyUI_IPAdapter_plus:

  • ComfyUI Manager: search "ComfyUI Essentials" β†’ Install β†’ restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/cubiq/ComfyUI_essentials, install requirements.txt, restart.

You'll know the pack's nodes by the πŸ”§ wrench and the + on the class name (BatchCount+).

Gotchas

The main thing to get straight is what "batch" means. A ComfyUI batch is items stacked on the batch dimension of a single tensor - the four images a KSampler produces when batch size is 4, for example. A list of separate items (the kind some nodes emit) is a different thing under the hood, and the count you get reflects the batch dimension, not necessarily every conceptual "item" if your data is structured as a list. If the number looks off, check whether your upstream node is producing a true batch or a list.

Beyond that there's little to trip over - it reads a dimension and returns it. The only standing caveat is pack-level: cubiq set ComfyUI Essentials to maintenance-only in April 2025. The nodes still work fine in general, but if this one ever goes red as "missing" after a ComfyUI update, the pack didn't load - check the startup log for an import error and reinstall through Manager, or roll ComfyUI back. Nothing's coming from upstream to fix it, so you maintain it yourself if it ever breaks.

Categoryessentials/utilities

Inputs (1)

NameTypeDefaultDescription
batch*β€”

Outputs (1)

NameTypeDescription
INTINTβ€”