Anything Get By Index
Pull one item out of a list or batch
- ANY
- *
A small, boring, genuinely useful node: give it anything with multiple items - a list of strings, a list of numbers, an image batch - and an index, and it returns just the one item at that position. Need the third caption out of a batch of ten? The fifth frame out of an image batch for a quick preview? This is the one-node way to do it instead of writing a custom index-select script.
How it works
The node's own description spells out its behavior across types, which is worth quoting directly since it's the whole point:
- For a single item (int/float/bool/str) - it just returns itself, ignoring
indexentirely. - For a list (str/int/float/bool) - it returns the item at
index. - For an image batch - it returns a single image, keeping the batch dimension (so downstream nodes expecting a batch tensor still get one, just with one image in it).
- For an image list - same, a single image with the batch dimension preserved.
That "single item passes through unchanged" behavior matters: if you wire in a plain scalar and start changing index, don't be confused when nothing happens - that's documented, expected behavior, not a bug.
Inputs and output
Just two inputs: ANY (typed *, accepts literally anything) and index (an integer, default 0). One output, also typed *, carrying whatever was selected.
Conceptually this sits in the same "generic glue" territory as rgthree-comfy's Any Switch - both exist because ComfyUI graphs constantly need to pick one value out of several without the author having built a type-specific node for every case. The difference is what they select on: Any Switch picks between separate named inputs, this one indexes into a single collection input. Different shape, same underlying itch.
Installing it
ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/yorkane/ComfyUI-KYNode
Restart ComfyUI. No dependencies, no downloads - pure Python logic. This is a small personal-toolbox pack (confirmed via a search of the ComfyUI community discussion, which turns up essentially nothing on it or its author) rather than a widely-adopted staple, so this is very much a "useful when you need it" node rather than something you'll see recommended in workflow write-ups.
Common issues
Because both the input and output are wildcard-typed (*), ComfyUI doesn't type-check the wire at graph-build time - if you plug this node's output into something expecting a specific type (an IMAGE socket, say) and what actually comes through is a string, you won't find out until the graph runs and that downstream node throws. This is a general footgun with any *-typed utility node in ComfyUI, not specific to this one, but worth knowing before you chase a confusing runtime error.
An out-of-range index on a short list isn't documented here, so assume it'll error rather than silently clamp or wrap - keep your index inside the actual length of whatever you're indexing into, especially if that length varies at runtime (a batch size that depends on an upstream node's output, for instance).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| ANY | * | — | |
| index | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |