Index Anything
Grab frame 3, or the second item in a list — Index Anything
- any
- out
Every now and then you need to reach into a batch and pull out one thing. A frame out of a video's latent batch. The second prompt out of a list. One specific mask out of a stack. That's the whole job of wcx_IndexAnything - a wildcard index node that takes any type, an integer, and hands you back the element at that position.
The interesting part is how it decides what to index, because the node is declared INPUT_IS_LIST, which in ComfyUI means every wire connected to the single any socket arrives as a list. The logic then goes:
- One tensor connected → it indexes along the batch dimension and returns a one-element slice (so a batch of 16 latents with
index3 gives you frame 3, still shaped as a length-1 batch). - One list or tuple connected → it picks the element at that position.
- One scalar/string value → it just returns it unchanged; the index is ignored.
Negative indexes wrap from the end (-1 is the last element), and out-of-range indexes clamp to the nearest valid one instead of erroring. Nothing ever crashes here - it's all "give me something reasonable" behavior, which is nice until it hides a bug.
The inputs are just the two: any (connect whatever - an IMAGE, LATENT, MASK, STRING list, anything) and index (INT, default 0, range −1,000,000 to 1,000,000). Output is out, same type as what you fed in.
Where this earns its keep:
- Pulling one frame out of a latent batch to inspect or to feed a node that only takes a single image.
- Selecting one prompt from a list of prompts wired through a list-capable node.
- Grabbing a single mask out of a mask batch before a mask op that doesn't accept batches.
Gotchas worth knowing before you wire it in:
- It returns a length-1 batch slice, not a squeezed value. A frame pulled from a batch still has its batch dimension, so nodes expecting a plain 2D mask may complain. You're often one squeeze away from the shape you want.
- Because the type is
*, validation is skipped. ComfyUI will happily let you feed a latent and connect the output to a mask input; you won't find out until downstream explodes. The node can't - and won't - tell you. - Indexing into nothing returns the value itself, so if you connect a non-container you may think it's broken when it's actually just passing through.
Standard light install, no dependencies beyond the pack itself:
# ComfyUI Manager: search "ComfyUI-Practical-Tools" → Install → restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
# restart ComfyUI
It's a tiny utility, but it's the one I'd reach for over a bespoke "index batch" node - it does exactly one thing and does it for any type.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| any | * | — | |
| index | INT | 0-1000000–1000000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| out | * | — |