Select Item
Pluck the Nth thing out of a pile of wires
- values
- *
Batch workflows have a habit of dumping a whole pile of things on you - a list of prompts, a stack of seeds, an array of images - when what you actually want is one of them. JN_SelectItem is the tool for that: feed it a pile, give it an index, get back the single item at that position. It's one of the quiet utility nodes in JNComfy's Primitive > Process family that you don't think about until you need exactly it.
How it works
The node takes values - one input that becomes many as you wire things in - plus an integer index, and hands back values[index]. Three details make it more useful than a naive index:
merge_array_items(default on) - before indexing, any arrays in the inputs are flattened into one list. Feed it three images and an array of four strings and it treats them as a single seven-item list, not four separate groups.only_active(default on) -Nonevalues are dropped first. An empty or unconnected input slot doesn't consume an index position.- Index wrap-around - the index is taken modulo the list length. Ask for index 7 of a 5-item list and you get item 2 instead of an error.
If nothing is selected - empty input, or every slot None - it outputs None.
The values input is the pack's "multiple" input type: it starts as one slot, and every time you connect something, a new values[N] slot appears (courtesy of JNComfy's multipleInputs.js). You don't decide how many items it takes; the graph does.
The inputs that matter
- index - which item to grab. Default 0. You can type a fixed number or convert it to an input and wire a
JN_PrimitiveInt, a math node, or a counter into it to cycle through a list automatically. only_active- leave it on unless you specifically want empty slots to count as positions.- values - the dynamic list itself.
Output is a single * - whatever type you put in, that's what comes out.
Where you'd use it
Everywhere you batch. Pick the third prompt out of a prompt array for a comparison run. Grab one frame or one image out of a stack for closer inspection. Or wire a counter into index and let one SelectItem act as a poor man's iterator, stepping through a list each time the workflow runs. It sits alongside the pack's other array tools - JN_SliceOperation for grabbing a range, JN_FirstActive for "first thing that isn't empty" - so for a single pick, this is the one.
One thing worth knowing: because JNComfy enables the generic * type (the README's "easy generic inputs" patch), SelectItem happily accepts images, strings, numbers, even CONDITIONING - no type gymnastics, no Anything-Anywhere-style rerouting hacks.
Install
It's part of JNComfy, so: ComfyUI Manager → search "JNComfy" → Install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui
and restart. Manager handles the (heavy) requirements.txt for you; the pure-Python Primitive/Process nodes like this one don't actually need any of it, but the install pulls everything anyway - that's the price of the pack's audio/face-restore sections.
Gotchas
The classic surprise is only_active. With it on (default), index positions count connected values only. If you expect index 2 to be the third slot but slot 0 is unconnected, you'll actually get the value after the one you expected - index positions shift because the empty slot never enters the list. If you pick an index that's out of range you get wrap-around rather than None - handy, but it means typos don't surface as errors, they surface as "why did it give me the first one again?"
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 00–18446744073709550000 | — |
| only_active | BOOLEAN | true | — |
| merge_array_items | BOOLEAN | true | — |
| valuesopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |