ComfyUI Node

Prompt Switch (10)

Swap between ten prompts with one number — no graph surgery

By itom0717·Created 6 months ago·Updated 6 months ago· 0
Prompt Switch (10)
    • selected_text
    id1
    text_01
    text_02
    text_03
    text_04
    text_05
    text_06
    text_07
    text_08
    text_09
    text_10

    You've got a workflow that's basically good, except every character or style variant means a different prompt block - and you've been handling that by duplicating the whole graph and editing one string. Stop doing that. Prompt Switch (10) from itom0717's Prompt String Selector pack is the node that turns "which prompt runs" into a single integer.

    What it is

    A string router. It takes an id (an INT from 1 to 10) and passes through exactly one of the ten text_01text_10 inputs you've connected, out as selected_text. Change the number, get a different prompt. No rewiring, no copy-paste, and because id is a real input you can drive it from another node - one workflow, ten variants, flip a number (or wire a random INT into id if you want chaos).

    One thing to clear up fast: despite the name, this is not the "prompt switch" you see in A1111-land - the [Dog|Cat] thing that alternates tokens every N steps. That's prompt scheduling; comfyui-prompt-control and KepPromptLang do that. This node is a static router: pick one connected string, output it. Both get called "switch" and they solve different problems. If you came here wanting per-step alternation, wrong node.

    How it works

    Read the source and it's delightfully simple:

    • id is required, INT, default 1, min 1, max 10.
    • The input labels are two-digit: text_01 through text_10, not text_1. Easy to miss when you're poking at workflow JSON.
    • The chosen string gets whitespace-stripped and a ,\n appended unless it already ends in a comma. That trailing comma is deliberate - the output is meant to chain into the pack's Aggregator or into a CLIP text encode alongside other prompt parts.
    • If the pin for the chosen id isn't connected, or is empty, you get an empty string. No error, no fallback. This is the thing that bites people: the node never crashes, so "my prompt vanished" is almost always "I switched to an id whose pin is empty."

    The inputs and outputs that matter

    id is the one you actually touch. text_01text_10 are optional STRINGs with forceInput set, so they want to be wired - from the pack's Character or Art Style selectors, from a PrimitiveStringMultiline, anywhere a string lives. The output is selected_text (STRING), which feeds your CLIP Text Encode or an aggregator.

    The pack's sample workflow shows the pattern: an ID Select node feeds id into a Prompt Switch, whose selected_text drops into an Aggregator next to Character and Art Style selectors. Character A or character B becomes one integer.

    Install

    Same as the whole pack - pure Python, no requirements, no model downloads, MIT license:

    cd ComfyUI/custom_nodes
    git clone https://github.com/itom0717/ComfyUI-Prompt-String-Selector
    

    Restart ComfyUI (a page refresh too, so the nodes register). Or use ComfyUI Manager → Install via Git URL with the same repo address.

    Gotchas worth knowing

    • An id out of range - say, 11 fed from an upstream node - looks for text_11, finds nothing, and silently outputs an empty string. Clamp it upstream or you'll chase ghosts.
    • Nothing auto-advances. It's a router, not a randomizer; randomness is your job to add.
    • Ten inputs is a lot of wires on canvas. If you only have two or three variants, the (5) version is the same node with less clutter.

    Which one do you actually want? For most people, honestly, this one. Ten variants is a sane ceiling and the middle child here is the right default. You'll know you need the (20) when you're running a real prompt library with more than ten entries.

    CategoryPrompt String Selector

    Inputs (11)

    NameTypeDefaultDescription
    idINT11–10
    text_01optSTRING
    text_02optSTRING
    text_03optSTRING
    text_04optSTRING
    text_05optSTRING
    text_06optSTRING
    text_07optSTRING
    text_08optSTRING
    text_09optSTRING
    text_10optSTRING

    Outputs (1)

    NameTypeDescription
    selected_textSTRING