Get from Index
One item out of any batch, without a node per type
- batch
- item
- index
- count
ComfyUI's core library has a dirty little secret: "grab item 3 out of this batch" is not one node, it's one node per type. Get Image from Batch for images. Latent From Batch for latents. Nothing at all for masks, audio, or a plain list of conditionings. So you either stack type-specific nodes, or you write a little Python node of your own for the type you happen to need today. Get from Index is the collapse of all of that into one node, and it's the least glamorous thing in Nynxz's pack and probably the one you'll keep.
What it actually does
The trick is that it never asks what type you wired in. It looks at the value. A tensor is batched on dimension zero. A dict is batched on whichever of samples or waveform holds a tensor - that's LATENT and AUDIO. A list or tuple is batched on its length, which covers CONDITIONING and anything a node hands back as a list. That's the whole dispatch table, and it's why the node works on types nobody anticipated when it was written.
It's built on ComfyUI's MatchType sockets, so the input socket accepts anything and the output socket takes the type you wired in. That matters more than it sounds: the graph still type-checks downstream, so you don't lose autocomplete or get a mystery red link when you feed the output into a sampler. The old any-type layer in ComfyUI plumbing leans on optional-equals-None and the * wildcard; this does it properly, with a real template type.
Where it earns its keep is on LATENT, because that payload carries company. Take item n out of a latent batch and the noise_mask comes with it, sliced on the same index. A single-frame noise_mask covers the whole batch and stays whole; a shorter one gets tiled, which is core's own LatentFromBatch rule. The output also gets a batch_index list, and sample_rate survives on audio. That's the difference between a node that works and one that quietly breaks your inpaint mask.
The inputs you actually touch
batch and index are required. index starts at 0, accepts negatives so -1 is the last item (same convention as core, so it's not a surprise sitting next to the nodes it replaces), and spans -4096 to 4096.
Then two optional fields that are the reason to prefer this over core:
length(default 1) takes a sub-batch fromindexinstead of a single item. It's trimmed to what's actually there, solength=4on a 2-item batch gives you 2 and doesn't throw.out_of_rangedecides what an index past the end means.clamptakes the nearest real item and matches core's behaviour, so it's the default and the safe one.wrapcounts round modulo the count, which is what you want when a counter is driving the index.errorstops the run with a message listing the valid range, and that's the one to pick when an out-of-range index means something upstream is wrong and you'd rather find out now than get a silently clamped frame.
Three outputs: item (your type back out), plus index and count. Those two are the underrated bit - index is the index after negatives and clamping were resolved, and count is how many items the batch held. Wire them into a text node or a filename and a wrapped index is visible rather than guessed at.
The trap beginners hit
The result keeps its batch dimension. Ask for one image and you get a batch of one, not a bare image. That's deliberate - it drops straight back into anything that took the original - but it means people who expected an unbatched tensor go looking for a bug that isn't there. It also means a batch-of-one will happily pass a Get Image from Batch downstream and look like nothing happened.
The other one is honest failure: index into an empty batch and it raises ("The batch is empty, so there is no item to get"), and indexing a dict payload that isn't batched on samples or waveform raises with the list of what it does handle. Custom pack types with their own dict shape aren't covered.
Installing it
Search Nynxz in ComfyUI Manager, or:
comfy node install comfyui-nynxz-nodes
From source it's the usual clone plus a frontend build - see below, because the build step is not optional here:
cd ComfyUI/custom_nodes
git clone https://github.com/Nynxz/ComfyUI-NynxzNodes
cd ComfyUI-NynxzNodes
pnpm install && pnpm build
Then restart ComfyUI. No Python dependencies; the pack declares none, and this node in particular is deliberately torch-free (it sniffs tensors by duck-typing shape and clone), so it can be unit-tested outside ComfyUI.
Troubleshooting
A plain git clone gets you the Python and none of the pack's panels - web/ is gitignored upstream and only the registry package ships it built. This node has no custom widget, so it survives that fine, but if you're mid-install and other Nynxz nodes are showing blank panels, that's the missing pnpm build, not a bug. ComfyUI Manager and the registry package skip the problem entirely.
The pack is written against the V3 schema API (from comfy_api.latest import io), so it needs a fairly recent ComfyUI. On an old build you'll get an import error at startup rather than a broken node - update first. And if you drive index from a counter, set out_of_range to wrap and also wire the index output somewhere visible; a clamped index looks exactly like a correct one.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| batch | COMFY_MATCHTYPE_V3 | Any batched value: an IMAGE or MASK batch, a LATENT, an AUDIO, a CONDITIONING, or a list. | |
| index | INT | 0-4096–4096 | Which item, from 0. Negative counts from the end, so -1 is the last — the same convention as core's Get Image from Batch. |
| lengthopt | INT | 11–4096 | How many items to take from `index`. 1 is a single item; more returns a smaller batch. Trimmed to what is actually there. |
| out_of_rangeopt | COMBO | clamp | What an index past the end means. 'clamp' takes the nearest real item, matching core's nodes. 'wrap' counts round, for driving this from a counter. 'error' stops the run, for when an out-of-range index means something upstream is wrong. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| item | COMFY_MATCHTYPE_V3 | — |
| index | INT | The index actually used, after negatives and out_of_range were resolved — so a wrapped or clamped index is visible rather than guessed. |
| count | INT | How many items the incoming batch held. |