Nodes/ComfyUI Easy Use/easy textIndexSwitch
ComfyUI Node Runs on cloud

easy textIndexSwitch

Pick one text input by number

By yolain·Created 3 years ago·Updated 8 days ago· 2,633
easy textIndexSwitch
    • text
    index0
    text0
    text1
    text2
    text3
    text4
    text5
    text6
    text7
    text8
    text9
    text10
    text11
    text12
    text13
    text14
    text15
    text16
    text17
    text18
    text19

    A boolean switch picks between two things. This one picks between many, by number. easy textIndexSwitch takes a stack of text inputs and an index, and outputs whichever text sits at that index. It's how you select one prompt (or filename, or any string) out of a list programmatically - set the index by hand, or better, drive it from something that changes, like a loop counter or a computed value, and you've got prompt-switching that reacts to the rest of your graph.

    What it's for

    The obvious use is a menu of prompts. Load up text0 through however many with different scene descriptions, and flip the index to choose which one runs - no rewiring, no deleting connections. Where it gets interesting is driving the index dynamically: pair it with easy forLoopStart's index output and each loop iteration selects a different text, so a single run walks through your whole list. Or compute the index with easy simpleMath and let some condition decide which prompt fires. That's the difference between a static switch and actual routing logic.

    The inputs and outputs that matter

    • index - the selector, an integer. It's the whole control surface; whatever number it holds picks the matching text slot.
    • text0, text1, text2, … (optional strings) - the candidate texts. Connect as many as you need; you can wire in string outputs from other nodes or type directly. Empty slots you leave unconnected.

    The single output is text - the selected string - which you send into a CLIP text encode, a loader prompt input, or anywhere a string belongs.

    Installing it

    Bundled with the pack. Install ComfyUI-Easy-Use via ComfyUI Manager (search ComfyUI Easy Use, restart) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yolain/ComfyUI-Easy-Use
    

    Install requirements, restart. Nothing else needed.

    Where it bites

    The main thing to watch is the index pointing at an empty or nonexistent slot. If index is 5 but you only wired up text0text2, you'll get an empty string (or an error, depending on version) rather than a helpful warning - and an empty prompt tends to fail quietly downstream rather than loudly. Keep the index inside the range of slots you actually connected, and if you're driving it from a loop, make sure the loop count and the number of texts line up.

    The other consideration is the same one that applies to every switch: the unselected inputs may still be evaluated. If a text slot is fed by an expensive chain (say a VLM captioner), that work can happen even when you didn't select it. For plain typed strings this costs nothing, so it's usually a non-issue here - but worth remembering if your text inputs come from heavy upstream nodes. As a clean "choose prompt N from this list" tool, though, it's exactly the right node, especially once you start driving the index instead of setting it by hand. If you need to switch non-text types, the pack has matching index-switch nodes for images and "anything."

    CategoryEasyUse/Logic/Index Switch

    Inputs (21)

    NameTypeDefaultDescription
    indexINT00–9
    text0optSTRING
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING
    text5optSTRING
    text6optSTRING
    text7optSTRING
    text8optSTRING
    text9optSTRING
    text10optSTRING
    text11optSTRING
    text12optSTRING
    text13optSTRING
    text14optSTRING
    text15optSTRING
    text16optSTRING
    text17optSTRING
    text18optSTRING
    text19optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING