BATCH TO ARRAY
Turn a batch tensor into items you can loop over
- value
- ARRAY
ComfyUI represents a batch - say, four images generated from the same prompt - as one tensor with an extra leading dimension, not four separate objects. That's efficient for the sampler and awkward for you the moment you want to treat each item individually: run something per-image, feed items one at a time into a node that only accepts a single item, or measure how many you actually got. JN_PrimitiveBatchToArray is the unpacking step that turns that one batched object into a JNComfy ARRAY of individual items.
It's from JNComfy (jn-jairo/jn_comfyui), a one-person pack of mostly-unrelated tools - audio, face restoration, sampling extensions, and this array/primitive family. There's essentially no community discussion of the pack anywhere; it's a personal toolkit made public rather than something with a following, so the README is genuinely the primary source here.
How it works
value is typed generically, not locked to IMAGE specifically - so while the overwhelmingly common case is unpacking a batched IMAGE or MASK, don't assume it only works on images; it'll take whatever batch-shaped object you hand it. Once unpacked into an ARRAY, the rest of the pack's array family becomes available: measure it with JN_PrimitiveArrayInfo, reduce it with JN_MathOperationArray, or feed individual items downstream.
This is a genuinely different job from JN_PrimitiveToArray, which is easy to confuse it with by name - that one bundles multiple separate wires into one array. This node instead unpacks one already-batched object's internal dimension. If you're converting several distinct inputs into a list, you want JN_PrimitiveToArray; if you're splitting a single stacked batch into its individual members, this is the one.
The inputs and outputs that matter
value(required, any type) - the batch to unpack.- Output:
ARRAY- one entry per item that was in the batch.
Installing it
ComfyUI Manager: search "JNComfy". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui
Restart ComfyUI. No models, no extra dependencies.
Common issues & troubleshooting
Feeding it something that isn't actually batched. A single, un-batched image will still "work" - you'll just get a one-item array back. That's not an error, but if you were expecting more than one entry, the problem is upstream: whatever produced value never actually batched multiple items together.
Confusing this with JN_PrimitiveToArray. See above - they solve opposite-shaped problems (unbundling one batch vs. bundling several separate wires). Reaching for the wrong one is the most likely source of a "why is my array only length 1" surprise.
Expecting an automatic round trip back to a batch. This pack's README lists an audio-specific array-to-batch converter, but nothing general-purpose is named alongside this node for images. If something downstream needs a real batch tensor back (not a JNComfy ARRAY), check the Conversion section of the README before assuming this reverses cleanly on its own.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| value | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| ARRAY | ARRAY | — |