Text Index Switch 4
The all-in-one prompt randomizer that drops the extra node
- text
- label
- index
Here's the thing most tutorial workflows hide from you: random prompt selection isn't one node, it's two. You need something to generate the index and something to switch on it. Text Index Switch 4 is the AUN pack's answer to that - it folds the index generator and the text switcher into a single node, with four selection modes, and it's the node I'd use for anything prompt-randomization related. It saves you a node and a wire, and those are the kinds of savings that add up across a hundred workflows.
What it does
It combines index generation (Select / Increment / Random / Range) with up to 20 text slots. You set a mode, and the node produces the index internally - no separate Random/Select INT node required - then outputs the matching text plus the label and the active index. The README's "how to randomly select a prompt" workflow uses the two-node setup with AUNRandomIndexSwitch; this node is the one-node version of that exact idea.
Inputs that matter
mode- the selector:Select(fixed index),Increment(cycle through the range, great for batch runs),Random(random within range),Range(pick from a list like1,2,5-8,12).minimum/maximum- the inclusive bounds for Random/Increment modes, clamped to your slot count.index- the current/target index (what Select mode uses, and what Increment cycles).slot_count- how many text slots are active, 1–20.range- the comma-separated index list for Range mode, e.g.1,2,5-8,12.text1–text20- the prompt slots, multiline, with dynamic-prompt support.
Outputs: text, label, and index (the active index - wire it into other controllers or filename builders).
How it works
The state lives in the node itself - it remembers its current index for Increment mode and cycles through the range, so consecutive runs step through your prompts in order. Random mode uses a proper system-random source, and Range mode parses the list (including 5-8 style spans) into a valid set, cycling through it predictably. There's also an IS_CHANGED-style re-execution trigger, so Random/Increment/Range modes actually re-run each time instead of getting cached by ComfyUI - the silent killer of "why is my random prompt stuck on the same one?" - is exactly what this avoids.
The label works like the other switches: connected nodes contribute their titles, otherwise the slot's text stands in. And because slot_count genuinely bounds the active slots, a maximum beyond your count just clamps instead of crashing.
Which of the four switches do you want?
- V1
TextIndexSwitch- bare switch, cleanest when you're feeding the index from elsewhere. TextIndexSwitch3- adds the first-line-as-label convention and an index output; great for hand-organized prompt cards.TextIndexSwitch4- index generation built in, the all-in-one. This is the one for "give me random prompts" with the fewest moving parts.
For most people, the honest answer is: start here. One node, four modes, no extra wiring.
Installing
Ships in the AUN ComfyUI Nodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/loz2754/AUN-ComfyUI-Nodes
Restart ComfyUI, or use ComfyUI Manager (search "AUN"). No models, no heavy deps beyond the pack standard (auto-installed by Manager, or pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt for manual clones).
One tip before you run it: if you're using Increment mode for a batch, set maximum to exactly your slot count and keep minimum at 1 - otherwise the cycle range and the slot list can disagree, and you'll wonder why slot 12 never gets picked.
Inputs (26)
| Name | Type | Default | Description |
|---|---|---|---|
| minimum | INT | 11–20 | The minimum index for selection (inclusive). |
| maximum | INT | 101–20 | The maximum index for selection (inclusive). |
| mode | COMBO | Select | Select mode: Select for fixed index, Increment for cycling through range, Random for random index within range, Range for selecting from a list of indices. |
| index | INT | 11–20 | Current or target index, constrained by slot_count). |
| slot_count | INT | 21–20 | Number of visible text slots. |
| range | STRING | 1,2,5-8,12 | A comma-separated list of indices or ranges to select from in Range mode (e.g. 1, 2, 5-8, 12). |
| text1 | STRING | Slot 1 | — |
| text2 | STRING | Slot 2 | — |
| text3 | STRING | Slot 3 | — |
| text4 | STRING | Slot 4 | — |
| text5 | STRING | Slot 5 | — |
| text6 | STRING | Slot 6 | — |
| text7 | STRING | Slot 7 | — |
| text8 | STRING | Slot 8 | — |
| text9 | STRING | Slot 9 | — |
| text10 | STRING | Slot 10 | — |
| text11 | STRING | Slot 11 | — |
| text12 | STRING | Slot 12 | — |
| text13 | STRING | Slot 13 | — |
| text14 | STRING | Slot 14 | — |
| text15 | STRING | Slot 15 | — |
| text16 | STRING | Slot 16 | — |
| text17 | STRING | Slot 17 | — |
| text18 | STRING | Slot 18 | — |
| text19 | STRING | Slot 19 | — |
| text20 | STRING | Slot 20 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| label | STRING | — |
| index | INT | — |