π Array Get Item
Pluck one line out of a list, including from the end
- Item
- Count
One line, by number
If you keep a prompt bank, a list of style modifiers, or a hundred filenames in one text node, this is the node that turns that list into a single usable value. You give it the newline-separated list and an index; it gives you the line at that index, plus the total count.
That's it, and that's the point. It's the ComfyUI equivalent of list[n] - the smallest possible amount of logic, which happens to be exactly what most prompt-rotation setups need. Retype nothing; change an integer and get a different prompt.
How it works (and the bit that's genuinely nice)
The implementation splits the string on newlines, trims if you ask it to, checks the bounds, and returns the item - with support for negative indices. -1 is the last item, -2 the second-to-last. That is the Python convention and it's implemented as such, so it behaves the way anyone who's written a line of Python expects.
The bounds check is strict and loud:
Index 5 is out of range for array of length 3.
That's a RuntimeError that stops your run rather than an empty string. Annoying mid-batch, but honest - a silently empty prompt would be worse, and in a workflow where the index comes from a primitive you bump by hand, the error is actually the most useful feedback you'll get. Note the asymmetry with the pack's other nodes: π Array For Each also raises on out-of-range, while π Array Slice clamps like Python slicing does. Different failure styles for different jobs.
Inputs and outputs that matter
Array is socket-only (the pack sets force_input), so you can't type or paste the list here - feed it from π Array From Text, π List Files, π Read File, or any text node. This surprises people; it's intended.
Index is the only other field you'll touch: zero-based, negatives count from the end. Trim Items (on by default) strips whitespace from every line before indexing, which means the item you get back is clean even if the source list was pasted with ragged indentation.
Outputs: Item (STRING) and Count (INT). Item goes to a prompt, a caption, a filename, a π Delete File path. Count is worth wiring once in a while - drop it into a text preview when you're debugging why index 7 returns something unexpected; usually the answer is that the list only has five items.
A pattern that earns its keep
Negative indexing has one killer application: a mutually exclusive pair of options. Put two lines in a text node, wire this node's Item to your positive prompt, and switch between 0 and -1 when you want to compare. No second workflow, no copying prompts around.
Second pattern: a style rotation. Two of these nodes, one at index 0 and one at -1, joined downstream by π Array To Text with a , separator, gives you "first style, last style" per run. Crude, but it produces more variety than people expect and costs nothing.
Install
Manager: Extensions β Node Pack β search "Honda Nodes" β Install, then restart ComfyUI. Or by hand:
cd ComfyUI/custom_nodes
git clone --depth 1 https://github.com/Avaray/honda-nodes.git
cd honda-nodes
python install.py # ComfyUI's python; portable Windows: ..\..\..\python_embeded\python.exe install.py
The install.py step pulls the jq and ime binaries that the JSON and metadata nodes need. This node uses neither, so it will work without it - but the pack as a whole requires ComfyUI 0.38.0+, because it's authored entirely against the V3 schema with no legacy NODE_CLASS_MAPPINGS.
Common issues
Index out of range. You asked for line 10 and the list has 8. Remember blank lines count as items here - unlike π Array Length, this node does not ignore empties, so a trailing newline in your text block adds one. If you're indexing near the end, run the list through π Array Filter first with Remove Empty on and Trim on.
The item has a leading space. Trim Items got turned off. Turn it back on, or fix it upstream.
Nothing runs. As with every non-output node in this pack, execution only happens if an output node needs the result. If you're staring at an unchanged preview, check that your chain actually terminates in something that runs.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| array | STRING | Newline-separated array string. | |
| index | INT | 0 | Zero-based index of the item to retrieve. Negative indices count from the end. |
| trim_items | BOOLEAN | true | Strip leading and trailing whitespace from each item. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Item | STRING | β |
| Count | INT | β |