Nodes/ComfyUI-XJNodes/Random Text From List
ComfyUI Node

Random Text From List

A numbered prompt list where fixed, random, and ranged all make sense

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Random Text From List
  • multiline_text
  • STRING
type
choice1
seed0
index_list1, 2, 3

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_list defines a sub-set (default 1, 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-10 expands to 3, 5, 7, 8, 9, 10 (reverse ranges like 10-7 work 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.

CategoryXJNodes/text

Inputs (5)

NameTypeDefaultDescription
multiline_textXJ_NUMBERED_LIST
typeCOMBO3 options: fixed, random, list
choiceINT1
seedINT00–18446744073709550000
index_listoptSTRING1, 2, 3

Outputs (1)

NameTypeDescription
STRINGSTRING