List String Index
Pull one line out of a list, without a whole scripting pack
- list
- STRING
Two inputs, one output: give it a list, give it a number, get the string at that position. Zero-based, so 0 is the first item. That's the entire node.
Thin? Yes. But it's the missing half of a lot of graphs. Plenty of nodes hand you a list - Load Image Newest returns lists of filenames and captions, the pack's String to List exists precisely to make one, and any batch prompt node produces one. Plenty of widgets want a single string. ListStringIndex is the adapter between those two facts, and it's less hassle than dragging in a scripting suite for one [3].
The fields
list is the important one: it's a wildcard input, which means it accepts literally any socket but must be connected - you can't type a list into it. index is an integer widget, 0 to 9999, and the tooltip says exactly what you'd expect: zero-based index of the item to return. Output is a plain STRING.
That wildcard is worth understanding because it's how the graph-engine's escape hatch works: the node has no idea what type is arriving, and it stringifies whatever it finds. Connect an IMAGE and you won't get an error, you'll get a wall of tensor repr. Connect text and it behaves.
Two ways to use it
The obvious one: something produces four captions, you only want the third, so you index it and feed a text encoder or a filename builder.
The less obvious one is the reason I keep it around. Because index is an integer widget, it has a control_after_generate dropdown like any seed field - set it to increment and every queue walks one step through your list. Free prompt cycler: build a list of prompts, wire the output into your text encoder, hit queue five times and get five different prompts with no editing in between. Flip it back to fixed when you find the one you want.
Install
ComfyUI Manager → Rebalance Pack, or:
cd ComfyUI/custom_nodes
git clone https://github.com/nova452/Rebalance-Pack.git
# restart
No dependencies, no model downloads. The pack ships frontend JS, so hard-refresh the browser after you restart. The node lives in the Rebalance-Pack/foundational category. If you have the pack's pre-merge predecessor (ComfyUI-ConditioningKrea2Rebalance) still in custom_nodes, remove it first - same nodes, two folders, confusing menu.
Where it bites
"Index 3 out of range for list of length 2." Your upstream list is shorter than you think - usually because one of the image slots on the producing node was never wired. Count your actual items before assuming the node is wrong.
"Cannot index into an empty list." Upstream returned nothing at all. Same cause, worse case.
It returned a stringified blob instead of a filename. You fed it something that wasn't strings. Whatever you connect, you get str() of it, by design.
Indexing a list where you swear the item is there. The node handles the two shapes ComfyUI actually produces - a proper list of items, and a single node returning a whole Python list as one output - and unwraps the second case. It does not search, filter, or fuzzy match. Position only.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | * | A list of strings to pick from. | |
| index | INT | 00–9999 | Zero-based index of the item to return. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |