Nodes/AUN ComfyUI Nodes/Random Text Index Switch
ComfyUI Node

Random Text Index Switch

Random prompt picker with the index generator built in

By loz2754·Created 9 months ago·Updated 11 days ago· 7
Random Text Index Switch
    • text
    • label
    • index
    ◄minimum1►
    ◄maximum10►
    ◄modeRandom►
    ◄select1►
    ◄visible_inputs20►
    ◄text1►
    ◄text2►
    ◄text3►
    ◄text4►
    ◄text5►
    ◄text6►
    ◄text7►
    ◄text8►
    ◄text9►
    ◄text10►
    ◄text11►
    ◄text12►
    ◄text13►
    ◄text14►
    ◄text15►
    ◄text16►
    ◄text17►
    ◄text18►
    ◄text19►
    ◄text20►

    The classic ComfyUI prompt-rotation recipe is two nodes: a Random/Select INT to make an index, then a Text Index Switch to pick the matching text. Random Text Index Switch fuses those into one node - it generates the index and does the selection, with up to 20 text inputs, in a single place. Fewer nodes, fewer wires, fewer chances to mismatch your range against your socket count. It's the "one node instead of two" upgrade, and it's a genuine QoL win.

    How it works

    It has the same three modes as Random/Select INT - Select (fixed select value), Increment (cycle minimum→maximum), and Random (random within the range) - but instead of just outputting an index, it uses that index to pick one of the text1…text20 inputs and outputs the text. Three outputs: text (the picked string), label (a label for it), and index (the active index, in case something downstream needs to stay in sync).

    The inputs worth knowing:

    • minimum / maximum - the selection range. Set these to your actual number of filled text slots, not 20, or you'll roll empty sockets.
    • mode - Select/Increment/Random.
    • select - the fixed index for Select mode.
    • visible_inputs (2–20) - how many text sockets render on the node. Drop it to keep the node tidy when you only use five of twenty.

    Why you'd use it over the two-node combo

    • One place to configure. The range that controls the index and the number of text sockets you configured are right next to each other, so the classic "range doesn't match socket count" bug is much harder to hit.
    • The label output. The two-node pattern doesn't give you a label; this does. Wire label into a display node or use it for filenames via an AUN filename builder - knowing which prompt won without reading the whole text is genuinely handy.
    • Cleaner canvas. One node instead of two is the entire ethos of the AUN pack.

    Honest trade-off: if you need the same index to drive a text switch and a LoRA loader or a controller, the two-node pattern lets you split one index to multiple places. Here you'd take the index output and wire it onward - same effect, just remember the range you set is what the node uses, so keep it consistent.

    Install

    Part of AUN ComfyUI Nodes (loz2754):

    cd ComfyUI/custom_nodes
    git clone https://github.com/loz2754/AUN-ComfyUI-Nodes
    

    or ComfyUI Manager → search "AUN ComfyUI Nodes" → install → restart. Pack deps (piexif, opencv-python-headless, imageio-ffmpeg, requests) install via Manager; no model files, no keys.

    If your rotation needs Range-list mode (like 1,2,5-8), note this node is Select/Increment/Random only - pair AUN Random/Select INT with the pack's AUN Text Index Switch for that. For the everyday "randomize my prompts" job, this is the one.

    CategoryAUN Nodes/Prompts

    Inputs (25)

    NameTypeDefaultDescription
    minimumINT11–20The minimum index for selection (inclusive).
    maximumINT101–20The maximum index for selection (inclusive).
    modeCOMBORandomSelect mode: Select for fixed index, Increment for cycling through range, Random for random index within range.
    selectINT11–20The fixed index value to output when in 'Select' mode.
    visible_inputsINT202–20How many text input sockets to expose 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 (3)

    NameTypeDescription
    textSTRING—
    labelSTRING—
    indexINT—