List Index Selector
Grab the Nth item out of any list, type intact
- list_input
- selected_item
- list_length
List Index Selector is the list-flavored cousin of the pack's String Index Selector. Where that one splits a delimited string and picks the Nth piece, this one takes an already-built list and pulls out whichever item you point at. It's a tiny node, but it's the one that makes "iterate over this collection of things" workflows actually click together.
The headline feature is type preservation. Lists in ComfyUI are usually lists of whatever upstream produced - ints, floats, strings, even masks - and this node returns the item in its original type. An int stays an int, so you can wire selected_item directly into an INT input on another node without a string-to-int conversion in between. That's the difference between a working loop and a chain of type-cast nodes held together by hope.
How it works
Under the hood it declares INPUT_IS_LIST, so it receives the whole list in one go, unwraps the scalar inputs, and indexes in. The zero_indexed toggle decides whether index 0 means the first item (default) or 1 does. If the index is out of range it returns None plus the list length - no crash, just a null you'll want to route around.
The natural partner is String Splitter, which produces a typed list: split "10,25,42,100" as INT and you get [10, 25, 42, 100]; feed that into this node with index 2 and out comes the integer 42, ready to be a width, a seed, a frame number, whatever.
Inputs and outputs
list_input(*) - any list; it hasforceInput, so it won't run unconnected.index(INT, default 0) - which item to grab.zero_indexed(BOOLEAN, default true) - 0-based vs 1-based counting.
Outputs: selected_item (*) and list_length (INT). The length output is quietly useful - you can wire it into a comparison to know when your loop has run out of items.
Where you'd use it
The classic loop pattern: connect a loop index to index, and each iteration pulls a different value out of the same list - a different seed, a different prompt line, a different resolution. Combined with String Splitter you get "parse a CSV-ish string once, then walk it one entry per iteration," which the pack's README shows for extracting frame numbers to feed a Save Image node (frame_42.png, etc.).
Installing it
It's part of ComfyUI-JK-TextTools. ComfyUI Manager → search "JK-TextTools" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nakamura2828/ComfyUI-JK-TextTools.git
Restart ComfyUI. No models, no extra pip installs - this is pure Python.
The gotcha
That None on out-of-range is silent, and downstream nodes tend to fail with confusing messages when they receive None from a * output. If your workflow is flaky, check whether the index is going past list_length. And keep the zero_indexed toggle in mind when copying workflows from someone else - a 1-based loop pasted into a 0-based setup is off by one in the most maddening way.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| list_input | * | — | |
| index | INT | 00–10000 | — |
| zero_indexed | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| selected_item | * | — |
| list_length | INT | — |