Random Text From List
A numbered prompt list where fixed, random, and ranged all make sense
- multiline_text
- STRING
Random Text From List is the pack's "pick a prompt from a list" node, and it's the one you'll actually reach for when you want variation in a workflow. The README's framing says it: "useful for prompts, captions, tags, selection." You type a list into a numbered widget, and the node picks an entry - either a specific one, a random one, or a random one from a sub-range you specify. Three selection modes, one little text-list input.
The workflow that sells it is prompt roulette. You have ten style descriptors, ten camera angles, or ten artist tags. You want each generation to draw one, reproducibly. The Impact Pack's wildcard syntax ({a|b|c}) does this inline inside a prompt, but if you want the selection as a first-class value - one you can wire, inspect, and reuse across multiple nodes - this node is cleaner. It's also the rare text node that lets you be deliberately fixed: set type to fixed, pick a choice, and it's just a numbered lookup into your list.
How it works
The input is a special XJ_NUMBERED_LIST widget - a multiline box where lines become numbered list items. The parsing is more forgiving than you'd think: lines starting with - start a new item, lines starting with # are comments, and continuation lines join the previous item, so multi-line prompts survive as single entries. Then the three modes:
- fixed - return item
choice, with wrap-around (ask for item 99 in a 5-item list and you get item 4). A numbered lookup, nothing random - random - uniform random pick across the whole list, seeded
- list - the interesting one.
index_listdefines a sub-set (default1, 2, 3), and it picks randomly from that subset
Inputs and outputs
- multiline_text - the numbered list widget
- type - fixed / random / list
- choice - the fixed-mode index (1-based)
- seed - INT, default 0. Determinism for the random modes
- index_list - optional, default
1, 2, 3. For list mode, and it supports ranges:3, 5, 7-10expands to 3, 5, 7, 8, 9, 10 (reverse ranges like10-7work too)
The output is a single STRING.
Installing it
Same pack install. ComfyUI Manager → search "ComfyUI-XJNodes" → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
# restart ComfyUI
No dependencies. Category: XJNodes/text.
Getting the most out of it
Two tips from the parsing details. First, the # comment syntax and multi-line item support mean you can keep notes inside the list - a commented line between entries won't be picked, which is surprisingly handy when you're curating. Second, index_list with ranges is the power move: keep one master list of 30 prompts, and use 1-10 for one run, 11-20 for the next, without editing the list itself. The failure modes are mild: an empty list returns an empty string, and an index_list with no valid indices raises an error so you notice rather than silently getting nothing. If your text source lives in a file instead of the widget - say, a caption set you keep on disk - Random Text From File is the sibling that reads it for you.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| multiline_text | XJ_NUMBERED_LIST | — | |
| type | COMBO | 3 options: fixed, random, list | |
| choice | INT | 1 | — |
| seed | INT | 00–18446744073709550000 | — |
| index_listopt | STRING | 1, 2, 3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |