ComfyUI Node

Any List Selector

Pick One Thing Out of Any List — Backwards If You Like

By 5agado·Created 12 months ago·Updated 17 days ago· 1
Any List Selector
  • any_list
  • element
index0

The Any List Selector is exactly what it sounds like: you hand it a list, you give it an index, you get back the element at that spot. It sounds almost too trivial to ship, but it's one of those plumbing nodes you end up reaching for constantly once your workflows grow lists instead of single values.

Here's the thing that makes it more useful than the name suggests - negative indexing. Pass in -1 and you get the last element, -2 the second-to-last. If you're processing a list of images or prompts and you want "the one just added," you don't need to know the length. The description in the code calls this out explicitly: reverse access without counting.

What it takes and gives

The schema is as minimal as it gets:

  • any_list (*) - the list. Because the input type is *, this works on strings, images, latents, masks, whatever a node in your graph produces as a list.
  • index (INT, default 0) - which element to pull, negatives allowed.
  • Output: element (*) - one item, of whatever type the list held.

It's an input-is-list node, so it expects the incoming wire to actually be a list (a STRING list from a splitter, a batch of images, that kind of thing), not a single value. The classic pairing is with the pack's own String Splitter: split a comma-separated prompt list, feed the list in here, and cycle an index to pick which prompt runs this pass.

Installing it

Same as every node in the Sagado pack - there's no separate install for this one, no models, no dependencies beyond the pack's own requirements (torch, pillow, numpy). In ComfyUI Manager search for "Sagado Nodes for ComfyUI", or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/5agado/ComfyUI-Sagado-Nodes
pip install -r ComfyUI-Sagado-Nodes/requirements.txt

Then restart ComfyUI.

Where people get burned

The one real failure mode is an out-of-range index, and the node will tell you loudly: IndexError: Index X is out of range for list of length Y. If you're driving the index from a counter or another node, it's on you to clamp it - this node won't wrap around. It also won't coerce a scalar into a list, so if you wire a plain string into any_list you'll get confusing errors about indexing a string. Keep list outputs on the left side of this node and you're fine.

It's a dumb little node, but dumb nodes that do one job without breaking are half of why ComfyUI is usable at all.

CategorySagado-Nodes

Inputs (2)

NameTypeDefaultDescription
any_list*
indexINT0-9223372036854776000–9223372036854776000

Outputs (1)

NameTypeDescription
element*