ComfyUI Node

Select Index

Pick one item out of any list — list[index], in node form

By SeanScripts·Created 2 years ago·Updated 2 years ago· 79
Select Index
  • list
  • *
index0

Every now and then you have a list and you want one item out of it. Maybe it's the third caption from a batch, maybe it's one image from a folder load, maybe it's one match from a regex search. Select Index is list[index] as a node: give it a list and an integer, get back that one element.

Inputs: list (any type - literally *), index (default 0). Output: the item at that position, also any type. Zero-indexed, like every Python list, so index 0 is the first item.

The one trick that makes it useful

The list input is typed as * - "anything" - so this node wires into outputs that look scalar but are actually lists under the hood. ComfyUI is full of those: batch-of-anything inputs, the multi-match output of the pack's Regex Find All, string lists from Regex Split String. When a node refuses to accept a list where you want a single item, or you need one specific caption out of several, this is the bridge. The index input also takes a wire, so you can drive it dynamically - select the Nth item where N comes from somewhere else in the graph.

How it works

Under the hood it's Python's list[index], so the same rules apply: negative indexes count from the end (-1 = last item), and an out-of-range index throws an error. There's no bounds-checking nicety here - go past the end and the node fails. Keep your indexes within the list length.

Install

Part of the SeanScripts pack - ComfyUI Manager search ComfyUI-PixtralLlamaVision, or:

cd ComfyUI/custom_nodes
git clone https://github.com/SeanScripts/ComfyUI-PixtralLlamaMolmoVision

Restart after installing. No extra dependencies.

Troubleshooting

  • Index out of range error - the classic. Either your list is shorter than you think or the index is driven by a value that drifted too high. Add a length-check node if it's dynamic.
  • Returns a list anyway - you wired the output into something that coerces it; check what's on the other end. The output is genuinely a single item.

It's the unglamorous utility node you'll forget exists until the moment nothing else will unwrap a list for you. That's its job.

CategoryPixtralLlamaVision/Utility

Inputs (2)

NameTypeDefaultDescription
list*
indexINT0

Outputs (1)

NameTypeDescription
**