Nodes/WAS Node Suite v3/Text List Get
ComfyUI Node Runs on cloud

Text List Get

Pull one entry out of a list by position

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Text List Get
  • text_list
  • index
  • text
  • resolved_index
  • length
out_of_range

If the WAS text-list nodes are the pack's idea of an array API, Text List Get is the index operator: give it a list and a position, get one entry back as a string. It's the little gear that makes lists actually usable one-at-a-time, and it shows up everywhere loops are built.

What it does

Feed any list - the ARRAY output of Text Split to List, Text List, Text Dictionary Keys, or even a list of image paths - into text_list, give it an index, and out comes text, the entry at that position, as a STRING. If an entry isn't text to begin with (a list of numbers, say), it's converted as it comes out, so you always get something a text node can use.

The index behaves the way you'd hope if you've used Python: counting starts at 0, -1 is the last entry, -2 the one before it. Decimals get cut down to whole numbers, so driving it from a FLOAT source won't explode. The classic pairing is a Number Counter wired into index - step through a list one entry per run and do something with each.

The out-of-range decision

What happens when the index runs past the end is your call, and it's a real design choice rather than a formality:

  • wrap - counts round again, so index 5 of a 3-entry list gives entry 2. This is how you cycle a list forever from a counter that only climbs, which is exactly what a rotating prompt pool wants.
  • clamp - sticks at the first or last entry.
  • empty - returns nothing for that run.
  • error - stops the prompt. For when a missing entry means something upstream genuinely broke and you want to know immediately, not silently.

If you're iterating over a fixed list, wrap and clamp both keep you running; if the list length is a fact your workflow depends on, error is the honest choice.

The outputs worth reading

Beyond text, the node gives you resolved_index - the position actually read after wrap or clamp. It sounds redundant until a counter is driving the index and you want to know which entry the result really came from - for naming an output file after its prompt, say. There's also length, the entry count, so you can grab the list size without a separate Text List Length node sitting in the graph.

That's the whole node, and that's fine. It converts the pack's "list as a single value" world into the "one thing per run" world where samplers and text nodes actually live. If instead of one entry you want a whole run of them, use Text List Slice; if you want the count in several numeric forms, Text List Length is your friend.

Installing it

Part of WAS Node Suite v3 (WASasquatch's was-node-suite-comfyui, MIT). Search "WAS Node Suite v3" in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

Restart ComfyUI after installing. Requires ComfyUI 0.14.0+ and Python 3.10+; nothing extra to pip install.

CategoryWAS Suite/Text/List

Inputs (3)

NameTypeDefaultDescription
text_listARRAYThe list to read from, such as the LIST output of Text Split to List, Text List or Text Dictionary Keys.
indexINT,NUMBER,FLOAT0-99999999–99999999Which entry to take, counting from 0. -1 is the last entry, -2 the one before it. Wire a Number Counter in to step through the list one entry per run. A decimal value is cut down to a whole number.
out_of_rangeCOMBOWhat an index past the end does: `wrap` counts round again, `clamp` sticks at the first or last entry, `empty` returns nothing, `error` stops the prompt.

Outputs (3)

NameTypeDescription
textSTRINGThe entry at that position, as text. An entry that is not text is converted to it, so a list of numbers reads out as numerals.
resolved_indexINTThe position actually read, after wrapping or clamping. Worth watching when a counter drives the index, since it is the entry number the result really came from.
lengthINTHow many entries the list holds.