Nodes/ComfyUI Easy Use/easy indexAnything
ComfyUI Node Runs on cloud

easy indexAnything

Pull one item out of a list or batch

By yolain·Created 3 years ago·Updated 8 days ago· 2,633
easy indexAnything
  • any
  • out
index0

You've got a list of things - a batch of images, a list of strings, a stack of conditionings - and you want exactly one of them. The third image. The last prompt. Item zero. This node does that, and it doesn't care what the "thing" is.

That type-agnostic bit is the trick. Its single input accepts the wildcard * type, which in ComfyUI means "connect whatever you like." So the same node grabs an image out of an image batch, a caption out of a text list, or one entry out of any list some other node spat out. It lives in Easy-Use's Logic category alongside the switches, comparisons and loop nodes - the plumbing you use to make a graph decide things instead of running the same path every time.

Why you'd reach for it

The classic case: a node upstream produced several outputs and you only want to act on one. Maybe you generated a batch of four and want to send just the best index to an upscale. Maybe a wildcard node produced a list of populated prompts and you want line two. Maybe you're inside one of Easy-Use's for-loops and need the current item by number. Rather than splitting the batch or writing a Python node, you drop indexAnything and type the number.

How it works

Give it a collection and an integer; it returns the element at that position, counting from zero. Index 0 is the first item, 1 the second, and so on. It also supports negative indexing (added in v1.3.4), which counts from the end Python-style: -1 is the last item, -2 the second-to-last. That's genuinely handy when your list length varies run to run and you always want "the final one" without knowing how many there are.

The inputs and output

Two inputs, one output, nothing fancy:

  • any - the list or batch to index into. Accepts any type.
  • index - the position, an integer defaulting to 0, with a huge range (roughly ±1,000,000) so it never gets in your way. Negative values count from the end.

The output is out, also the wildcard * type, carrying whatever type you fed in. Wire it downstream exactly as if it were a single image, string, or whatever the source was.

Installing it

Install the pack via ComfyUI Manager - search ComfyUI Easy Use, install, restart. Or by hand: cd ComfyUI/custom_nodes && git clone https://github.com/yolain/ComfyUI-Easy-Use, install the requirements (install.bat on Windows or pip install -r requirements.txt), restart. No models, no extra dependencies - this is pure logic.

Where people trip

The one thing to know is the distinction between a list and a batch, because ComfyUI treats them differently under the hood, and whether a given upstream node hands you one or the other affects what "index" means. If the number seems to grab the wrong thing, check whether your source is emitting a batched tensor or an actual list - the node reads position either way, but the position that "line two" occupies can surprise you. And an out-of-range index will error rather than clamp, so if your list has three items, index 5 is a hard stop, not a silent last-item. Negative indexing is the clean way around "how long is this again?"

CategoryEasyUse/Logic

Inputs (2)

NameTypeDefaultDescription
any*
indexINT0-1000000–1000000

Outputs (1)

NameTypeDescription
out*