Random Text Index Switch V2
Prompt roulette with a label you can actually use
- text
- label
- index
- prefixed_label
This is the "one node instead of two" prompt randomizer, in the same spirit as Text Index Switch 4 - index generation and text selection fused together - but with an extra output that makes it genuinely better for building automated pipelines. The V2 suffix here buys you a prefixed_label: an index-and-name string like 3-cinematic that drops straight into filenames. If you're batch-generating and want each output to tell you which prompt produced it, that's the whole ballgame.
What it does
You give it up to 20 text inputs, pick a mode, and it generates an index then outputs the matching text. The four modes cover the usual ground:
Select- fixed index from theselectwidget.Increment- cycles throughminimum–maximum, stepping each run. Perfect for turning a batch of prompts into one run per prompt, in order.Random- uniform random within the range. The "surprise me" mode.Range- picks from an explicit list like1,2,5-8,12, cycling through it.
Inputs and outputs
Required: minimum, maximum (the inclusive bounds, clamped to your visible inputs), mode, select (the fixed index), range (the Range-mode list), and visible_inputs (2–20 sockets shown - hide the ones you're not using). Optional: text1–text20, which is what you actually wire your prompts into.
Outputs, and this is where it gets interesting:
text- the selected prompt. Wire into CLIP Text Encode.label- the selected slot's label (the connected node's title, or "Text N").index- the active index, for chaining into other nodes.prefixed_label- the V2 addition:index-label, e.g.3-cinematic. This is built for filenames. Feed it into a save node's template and every output file tells you at a glance which prompt made it.
How it works
Each run, the node clamps the range to your visible input count, generates the index per mode, then pulls the matching text. It reads the workflow data to find the title of the node connected to the selected slot - that's your label. The prefixed_label just strips any numeric prefix off the source title and prepends the index, so it stays clean even if your prompt node is itself named "3-cinematic".
Two implementation details matter in practice. First, in Random/Increment/Range modes the node forces re-execution every run, so ComfyUI's caching can't freeze your random prompt on the first value - the classic bug that makes people think the node is broken. Second, it records its state (mode, index, selected text) into the workflow's metadata, which is useful when you're auditing what actually ran.
V1 vs V2
The original AUNRandomTextIndexSwitch has the same modes and outputs text, label, and index. V2 adds the prefixed_label output. That's the entire difference, and it's a meaningful one if you care about filenames - which, if you're batch-generating prompts, you absolutely should.
Installing
It 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, which Manager installs or you add via pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt.
The only habit worth building: rename the nodes feeding your slots, because the label and prefixed_label outputs are only as good as those titles. Do that once and this becomes the quiet workhorse of your batch-prompt workflows.
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 | Random | Select mode: Select for fixed index, Increment for cycling through range, Random for random index within range, Range for selecting a range of indices. |
| select | INT | 11–20 | The fixed index value to output when in 'Select' mode. |
| 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). |
| visible_inputs | INT | 202–20 | How many text input sockets to expose on the node (2-20). |
| text1opt | STRING | Text input 1. Only the selected index is output. | |
| text2opt | STRING | Text input 2. Only the selected index is output. | |
| text3opt | STRING | Text input 3. Only the selected index is output. | |
| text4opt | STRING | Text input 4. Only the selected index is output. | |
| text5opt | STRING | Text input 5. Only the selected index is output. | |
| text6opt | STRING | Text input 6. Only the selected index is output. | |
| text7opt | STRING | Text input 7. Only the selected index is output. | |
| text8opt | STRING | Text input 8. Only the selected index is output. | |
| text9opt | STRING | Text input 9. Only the selected index is output. | |
| text10opt | STRING | Text input 10. Only the selected index is output. | |
| text11opt | STRING | Text input 11. Only the selected index is output. | |
| text12opt | STRING | Text input 12. Only the selected index is output. | |
| text13opt | STRING | Text input 13. Only the selected index is output. | |
| text14opt | STRING | Text input 14. Only the selected index is output. | |
| text15opt | STRING | Text input 15. Only the selected index is output. | |
| text16opt | STRING | Text input 16. Only the selected index is output. | |
| text17opt | STRING | Text input 17. Only the selected index is output. | |
| text18opt | STRING | Text input 18. Only the selected index is output. | |
| text19opt | STRING | Text input 19. Only the selected index is output. | |
| text20opt | STRING | Text input 20. Only the selected index is output. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| label | STRING | — |
| index | INT | — |
| prefixed_label | STRING | — |