Nodes/ComfyUI-TysiguUtilityNodes/TysiguDynamicSwitch
ComfyUI Node

TysiguDynamicSwitch

Pick which prompt feeds the workflow with one number

By tysigu-project·Created 5 months ago·Updated 5 months ago· 0
TysiguDynamicSwitch
    • text
    switch_index1
    text_1
    text_2

    If you've ever switched between two prompt lists - say, two characters or two styles - by deleting a wire and dragging a new one, you know it's the most pointless chore in ComfyUI. TysiguDynamicSwitch exists to make that a single number: connect several text sources, set switch_index, and the node passes the chosen one through. Change your mind? Change the number, not the wiring.

    It's a text-only switch, and that's the whole point. The heavyweight option in this space is something like rgthree's Context Switch, which is genuinely powerful but also carries a bundle of connections and has its own learning curve. This one takes plain STRING inputs, returns a STRING, and does nothing else. For "let me A/B two prompts without rebuilding my graph," that's all you need.

    How it works

    The mechanism is refreshingly direct. The node looks for an input named text_<switch_index> and returns it. If the slot you asked for isn't connected, it quietly falls back to the first connected text_N instead of erroring. That fallback is deliberate - the author built in a safety margin up to 999 slots - but it's also the one behavior that will bite you: point the switch at an empty slot and you don't get an error, you get whatever list happens to be connected first.

    The dynamic part happens in the frontend. The node starts with text_1 and text_2. Drag a wire onto the last empty pin and the extension adds text_3; connect that and you get text_4. Unplug trailing pins and it trims them back. It also clamps the switch_index widget's max to the highest connected slot, so the UI keeps you honest about what's actually available.

    The inputs and outputs

    • switch_index - the selector, default 1, min 1, max 999. Note it's 1-indexed, not 0-indexed. Slot 1 is text_1.
    • text_1, text_2 - the first two optional string inputs, both forceInput (you wire in a text source, you don't type). More appear as you connect them.

    Output: text - whatever input you selected, ready to feed a prompt encoder, the TysiguReadLines reader, or anything else that wants a string.

    Installing it

    It ships in the ComfyUI-TysiguUtilityNodes pack, so it's one install for all four nodes. Via Manager, search ComfyUI-TysiguUtilityNodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/tysigu-project/ComfyUI-TysiguUtilityNodes.git
    

    Then restart ComfyUI. No Python dependencies, no model files - this pack is pure stdlib plus frontend JS. (Side note: the README's own clone command contains a YourUsername placeholder; use the URL above.) The node lives under the Tysigu/Text category in the node menu.

    Where it gets fiddly

    • The fallback is silent. This is the one to remember. Set switch_index to a slot with no wire and the node returns the first connected input rather than complaining. If your outputs start looking wrong, check the index before you blame the node.
    • Pins appear by connecting, not by counting. You can't just dial switch_index up to 5; you have to actually wire in text_3, text_4, etc., or there's nothing to select.
    • It's 1-indexed. Muscle memory from every 0-based language will have you one off on the first try. The widget defaults to 1 and that's the first input.

    For the simple job - two or three prompt sources, swap by number - this node is exactly right. If you find yourself with a dozen inputs and want branch-on-type behavior, you've outgrown it and should look at the context/switch nodes in a bigger pack. But for A/B testing prompts without rewiring, this is the one you'll reach for.

    CategoryTysigu/Text

    Inputs (3)

    NameTypeDefaultDescription
    switch_indexINT11–999
    text_1optSTRING
    text_2optSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING