ComfyUI Node

String Switch

A/B your prompts by flipping one number

By HavocsCall·Created 2 years ago·Updated 9 months ago· 4
String Switch
    • String
    • Selection
    Selection1
    String_1
    String_2

    String Switch is the text version of the pack's switch family: two STRING inputs, one selection, one string out. It's the fastest way to A/B test prompts in ComfyUI short of installing a dedicated prompt-comparison toolkit.

    Why you'd reach for it

    Prompt A/B testing is one of the most common chores in this hobby, and doing it the awkward way - editing the prompt widget, rerunning, editing again - makes you lose the ability to compare like-for-like. Wire your base prompt into String_1, your variation into String_2, and flip Selection between runs. Same seed, same settings, only the string changes. That's a clean experiment, and it's exactly the kind of thing that separates "I think this works" from "I measured it."

    It's also handy for toggling between two negatives, two style suffixes, or two wildcard outputs. And because Selection is an INT, you can wire it to a random seed for a "pick a prompt each run" batch - crude but effective prompt roulette.

    How it works

    Standard pack switch pattern:

    case 1: return (String_1, Selection,)
    case 2: return (String_2, Selection,)
    

    Inputs:

    • Selection - 1 or 2.
    • String_1 and String_2 - both are forceInput string sockets, so they need to be wired from a Text Box, another string node, or a prompt loader. You can't just type into them.

    Outputs:

    • String - the winner, into your CLIPTextEncode or wherever.
    • Selection - passed through.

    Where people get burned

    String_2 is optional, and it's the easiest trap to fall into here because the inputs feel like text fields you could type into. They aren't - they're input sockets. Leave String_2 unwired and flip to 2 and you'll pass a None downstream, which CLIPTextEncode will not enjoy.

    The other thing to keep straight: switching the string doesn't re-encode anything until the graph runs. And like every switch in this pack, ComfyUI computes both connected branches - so both strings get encoded each run even though you only use one. Strings are cheap, so you won't feel it, but it's good to know the node is routing, not skipping work.

    Installing it

    ComfyUI Manager → search "HavocsCall" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HavocsCall/comfyui_HavocsCall_Custom_Nodes
    

    Restart, find it under HavocsCall/Switches. No requirements.txt, no model downloads - install is instant.

    CategoryHavocsCall/Switches

    Inputs (3)

    NameTypeDefaultDescription
    SelectionINT11–2
    String_1STRING
    String_2optSTRING

    Outputs (2)

    NameTypeDescription
    StringSTRING
    SelectionINT