Text Index Switch
The polite way to shuffle prompts without rebuilding the graph
- text
- label
Every serious ComfyUI user ends up with a wall of prompt nodes and a deep, tired desire to switch between them with one number. Text Index Switch is the AUN version of that switch: up to 20 text inputs, one index widget, and whatever input you point at comes out the other side. It's the glue node between a random/select integer and your CLIP Text Encode, and it's the one the pack's own "how to randomly select a prompt" example is built around.
What it does
You wire up to 20 text sources into text1 through text20, set an index (1–20), and it outputs the text from whichever input matches the index. The trick that makes it genuinely useful: the inputs take the title of the connected node, and that title is also used as the node's label output. Wire a "cinematic" prompt node into slot 2, and when index 2 is active you get both the text and a label that says "cinematic" - which you can feed into a filename builder or a display node.
Inputs and outputs
index- the selector, 1–20. Values above the visible count are clamped rather than erroring, so sloppy numbers don't break the run.visible_inputs- how many sockets to show, 2–20. This is the quality-of-life feature: you don't have to look at 20 empty sockets when you only use 4. The rest stay hidden but still work.text1–text20- the sources. Only the selected index's text is output.
Outputs: text (the selected string, wire it into CLIP Text Encode) and label (the connected node's title - perfect for filenames or a Show Text node).
How it works
It's a lazy-evaluation node, which is worth knowing: the text inputs use a lazy proxy, so ComfyUI only evaluates the input you actually selected. Wire ten prompt builders into it and it won't waste time computing the nine you didn't pick. The label comes from reading the workflow data - the title of the node connected to the selected slot - which is why the labels update when you rename your prompt nodes.
The classic setup
The pack's README example is still the best introduction:
- Add
AUN Random/Select INT(AUNRandomIndexSwitch) andAUN Text Index Switch. - Wire the
INToutput intoindex. - Set the Random/Select node to Random, define min/max to match your text inputs.
- Fill in prompts on the switch.
- Connect
textto CLIP Text Encode.
That gives you random prompt selection in five steps, and it's the template for everything from random characters to random styles to random negative prompts. If you want the same thing in one node, the pack's Text Index Switch 4 builds the index generation in - but this one is the simpler, more readable option when you want to see the logic.
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 dependencies - just the pack's standard requirements, auto-installed by Manager or via pip install -r custom_nodes/AUN-ComfyUI-Nodes/requirements.txt.
The only real gotcha: the label output depends on the source node having a meaningful title. If you never rename nodes, every label will be the node type ("CLIP Text Encode (Positive Prompt)") rather than something useful. Rename your prompt nodes - it takes ten seconds and makes the label output actually worth wiring anywhere.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 11–20 | Index number (1-20) to select which text input to output. Values above the visible count are clamped. |
| visible_inputs | INT | 202–20 | How many text input sockets to display 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 (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| label | STRING | — |