Nodes/AUN ComfyUI Nodes/Text Index Switch
ComfyUI Node

Text Index Switch

The polite way to shuffle prompts without rebuilding the graph

By loz2754·Created 8 months ago·Updated a day ago· 5
Text Index Switch
    • text
    • label
    index1
    visible_inputs20
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8
    text9
    text10
    text11
    text12
    text13
    text14
    text15
    text16
    text17
    text18
    text19
    text20

    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.
    • text1text20 - 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:

    1. Add AUN Random/Select INT (AUNRandomIndexSwitch) and AUN Text Index Switch.
    2. Wire the INT output into index.
    3. Set the Random/Select node to Random, define min/max to match your text inputs.
    4. Fill in prompts on the switch.
    5. Connect text to 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.

    CategoryAUN Nodes/Prompts

    Inputs (22)

    NameTypeDefaultDescription
    indexINT11–20Index number (1-20) to select which text input to output. Values above the visible count are clamped.
    visible_inputsINT202–20How many text input sockets to display on the node (2-20).
    text1optSTRINGText input 1. Only the selected index is output.
    text2optSTRINGText input 2. Only the selected index is output.
    text3optSTRINGText input 3. Only the selected index is output.
    text4optSTRINGText input 4. Only the selected index is output.
    text5optSTRINGText input 5. Only the selected index is output.
    text6optSTRINGText input 6. Only the selected index is output.
    text7optSTRINGText input 7. Only the selected index is output.
    text8optSTRINGText input 8. Only the selected index is output.
    text9optSTRINGText input 9. Only the selected index is output.
    text10optSTRINGText input 10. Only the selected index is output.
    text11optSTRINGText input 11. Only the selected index is output.
    text12optSTRINGText input 12. Only the selected index is output.
    text13optSTRINGText input 13. Only the selected index is output.
    text14optSTRINGText input 14. Only the selected index is output.
    text15optSTRINGText input 15. Only the selected index is output.
    text16optSTRINGText input 16. Only the selected index is output.
    text17optSTRINGText input 17. Only the selected index is output.
    text18optSTRINGText input 18. Only the selected index is output.
    text19optSTRINGText input 19. Only the selected index is output.
    text20optSTRINGText input 20. Only the selected index is output.

    Outputs (2)

    NameTypeDescription
    textSTRING
    labelSTRING