Nodes/ComfyUI-Desert-Pixel-Nodes/DP 3 String Switch Or Connect
ComfyUI Node

DP 3 String Switch Or Connect

Pick one of three prompts, or glue them together

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
DP 3 String Switch Or Connect
    • TEXT
    • CURRENT_INDEX
    modeSwitch
    index1
    String_01
    String_02
    String_03

    This is the two-jobs-in-one text node. Feed it up to three strings and it'll either pass exactly one of them through (switch), or stitch all of them into a single string (connect) with a joiner you choose. That "or" in the name is the whole point - most switch nodes only switch, this one also does the concatenation you'd otherwise reach for a second node to do.

    It's part of the Desert Pixel pack, a large collection of quality-of-life nodes. Like rgthree's utilities, nothing here generates an image; it just makes wiring text through a graph less tedious. Think of this as building blocks for a prompt: three fragments you can either select between or assemble.

    How it works

    Two dials drive it. mode decides whether you're switching or connecting, and index decides which input matters when you're switching.

    The mode dropdown has five options:

    • Switch - output only the one string at index.
    • Connected - join all the connected strings back to back.
    • Connected with comma - join them with , between, the usual prompt separator.
    • Connected with line break - join them one per line.
    • Connected with line break+ - join with extra line spacing.

    So the same node is a selector when you set mode to Switch, and a prompt assembler when you set it to any of the Connected modes. Comma-join is the one you'll use most for stacking prompt chunks; the line-break modes are handy for things that expect one entry per line, like some scheduling and travel formats.

    The inputs and outputs that matter

    • mode - switch vs. one of the four connect styles (above).
    • index - an integer from 1 to 3. Only used in Switch mode; it points at String_01, String_02, or String_03.
    • String_01, String_02, String_03 - optional multiline inputs. Because they're optional you can leave gaps; connect only the ones you need.

    Outputs are TEXT (the result string) and CURRENT_INDEX (an integer). That second output is more useful than it looks - in Switch mode it tells you which input was chosen, so if you're driving index from a counter to cycle through options, you can log or display exactly where you are.

    Need more slots? The 5-input and 10-input versions are identical in spirit with more strings (the 10-input one even adds a mode that strips negative text). Three is the sweet spot when you've got a subject, a style, and a quality tail to juggle.

    How to install it

    • ComfyUI Manager: search "Desert Pixel", install, restart. Nothing to download.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes, pip install -r requirements.txt if present, restart.

    Find it under the DP category in the node browser.

    Common issues

    The classic confusion is setting mode to a Connected option and then wondering why index does nothing. It's supposed to do nothing there - index only bites in Switch mode. In the connect modes every wired string is used regardless of index.

    The other gotcha is empty inputs. If a string slot is left unconnected, it contributes nothing to a connect, which is usually what you want, but it also means a Switch pointed at an empty slot outputs an empty string. If your prompt suddenly went blank, check that index is pointing at a slot you actually filled.

    CategoryDP/text

    Inputs (5)

    NameTypeDefaultDescription
    modeCOMBOSwitch5 options: Switch, Connected, Connected with comma, Connected with line break, Connected with line break+
    indexINT11–3
    String_01optSTRING
    String_02optSTRING
    String_03optSTRING

    Outputs (2)

    NameTypeDescription
    TEXTSTRING
    CURRENT_INDEXINT