Nodes/comfyui-uonr-nodes/Text Switch Stack
ComfyUI Node

Text Switch Stack

One prompt, up to 32 toggled parts — Text Switch Stack

By uonr·Created 5 months ago·Updated 5 months ago· 0
Text Switch Stack
    • STRING
    auto_commatrue
    text_count1
    enabled_1true
    part_1
    enabled_2true
    part_2
    enabled_3true
    part_3
    enabled_4true
    part_4
    enabled_5true
    part_5
    enabled_6true
    part_6
    enabled_7true
    part_7
    enabled_8true
    part_8
    enabled_9true
    part_9
    enabled_10true
    part_10
    enabled_11true
    part_11
    enabled_12true
    part_12
    enabled_13true
    part_13
    enabled_14true
    part_14
    enabled_15true
    part_15
    enabled_16true
    part_16
    enabled_17true
    part_17
    enabled_18true
    part_18
    enabled_19true
    part_19
    enabled_20true
    part_20
    enabled_21true
    part_21
    enabled_22true
    part_22
    enabled_23true
    part_23
    enabled_24true
    part_24
    enabled_25true
    part_25
    enabled_26true
    part_26
    enabled_27true
    part_27
    enabled_28true
    part_28
    enabled_29true
    part_29
    enabled_30true
    part_30
    enabled_31true
    part_31
    enabled_32true
    part_32

    Text Switch Stack answers the eternal workflow question "how do I turn one part of my prompt off without deleting it?" instead of the other classic - "which of these prompts do I pick?" - and that distinction is the whole thing. Where rgthree's Text Switch selects one input out of many, this node takes up to 32 text slots, lets you tick each one on or off, and merges the enabled ones into a single string. Build your prompt out of swappable chunks - subject, style, lighting, quality tags - and A/B test by flipping booleans instead of retyping prompts.

    How it works is refreshingly legible. Each slot has an enabled_ toggle and a part_ text box (multiline, so multi-line blocks are fine). On execution it walks the slots in order, skips any that are disabled or empty, and joins what's left. The merge isn't a comma-space join, which catches people out: parts are joined with newlines, and the auto_comma option (on by default) appends a trailing English comma to every part except the last - only when the part doesn't already end in one. So the default output for three parts is:

    subject,
    style,
    quality tags
    

    If that trailing-comma-then-newline style annoys you - and plenty of people expect ", " - flip auto_comma off and write your own separators into the parts. There's no separator setting, so that's the trade.

    The inputs that matter:

    • text_count - how many slots show up, from 1 to 32. This controls how many are processed, and it's where the trap lives: lower it to 2 when your text is sitting in part 3, and part 3 silently stops counting. The node's own front-end JS hides the widgets beyond the count so you can watch it happen.
    • auto_comma - the trailing-comma behavior above.
    • enabled_N / part_N - one pair per slot; only enabled, non-empty parts reach the output.

    Output is a single STRING, ready for a positive prompt input, a text-encode node, or a CLIP conditioning.

    Install is the pack's standard trivial route. ComfyUI Manager, search comfyui-uonr-nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/uonr/comfyui-uonr-nodes
    

    Restart ComfyUI. No dependencies, no models - this is a pure-front-end-plus-one-function node. Worth knowing the dynamic slot behavior relies on the default LiteGraph front end; in the stock UI it collapses and expands as you change text_count, which is the nicest part of the experience.

    Realistic gripes: because enabled and part are fixed widget pairs, you can't wire a slot from another node's string output - it's typing or pasting only. And with the newline join plus auto-comma, you should test one output before trusting a 32-slot monster into a workflow. But for the common case - a handful of prompt chunks you keep swapping - it beats juggling a dozen Muted node groups, and that's a real win.

    Categorytext

    Inputs (66)

    NameTypeDefaultDescription
    auto_commaBOOLEANtrueAppend an English comma to every enabled part except the last one when needed.
    text_countCOMBO1Number of text slots to show and process.
    enabled_1optBOOLEANtrueInclude text 1 in the merged output.
    part_1optSTRINGText part 1.
    enabled_2optBOOLEANtrueInclude text 2 in the merged output.
    part_2optSTRINGText part 2.
    enabled_3optBOOLEANtrueInclude text 3 in the merged output.
    part_3optSTRINGText part 3.
    enabled_4optBOOLEANtrueInclude text 4 in the merged output.
    part_4optSTRINGText part 4.
    enabled_5optBOOLEANtrueInclude text 5 in the merged output.
    part_5optSTRINGText part 5.
    enabled_6optBOOLEANtrueInclude text 6 in the merged output.
    part_6optSTRINGText part 6.
    enabled_7optBOOLEANtrueInclude text 7 in the merged output.
    part_7optSTRINGText part 7.
    enabled_8optBOOLEANtrueInclude text 8 in the merged output.
    part_8optSTRINGText part 8.
    enabled_9optBOOLEANtrueInclude text 9 in the merged output.
    part_9optSTRINGText part 9.
    enabled_10optBOOLEANtrueInclude text 10 in the merged output.
    part_10optSTRINGText part 10.
    enabled_11optBOOLEANtrueInclude text 11 in the merged output.
    part_11optSTRINGText part 11.
    enabled_12optBOOLEANtrueInclude text 12 in the merged output.
    part_12optSTRINGText part 12.
    enabled_13optBOOLEANtrueInclude text 13 in the merged output.
    part_13optSTRINGText part 13.
    enabled_14optBOOLEANtrueInclude text 14 in the merged output.
    part_14optSTRINGText part 14.
    enabled_15optBOOLEANtrueInclude text 15 in the merged output.
    part_15optSTRINGText part 15.
    enabled_16optBOOLEANtrueInclude text 16 in the merged output.
    part_16optSTRINGText part 16.
    enabled_17optBOOLEANtrueInclude text 17 in the merged output.
    part_17optSTRINGText part 17.
    enabled_18optBOOLEANtrueInclude text 18 in the merged output.
    part_18optSTRINGText part 18.
    enabled_19optBOOLEANtrueInclude text 19 in the merged output.
    part_19optSTRINGText part 19.
    enabled_20optBOOLEANtrueInclude text 20 in the merged output.
    part_20optSTRINGText part 20.
    enabled_21optBOOLEANtrueInclude text 21 in the merged output.
    part_21optSTRINGText part 21.
    enabled_22optBOOLEANtrueInclude text 22 in the merged output.
    part_22optSTRINGText part 22.
    enabled_23optBOOLEANtrueInclude text 23 in the merged output.
    part_23optSTRINGText part 23.
    enabled_24optBOOLEANtrueInclude text 24 in the merged output.
    part_24optSTRINGText part 24.
    enabled_25optBOOLEANtrueInclude text 25 in the merged output.
    part_25optSTRINGText part 25.
    enabled_26optBOOLEANtrueInclude text 26 in the merged output.
    part_26optSTRINGText part 26.
    enabled_27optBOOLEANtrueInclude text 27 in the merged output.
    part_27optSTRINGText part 27.
    enabled_28optBOOLEANtrueInclude text 28 in the merged output.
    part_28optSTRINGText part 28.
    enabled_29optBOOLEANtrueInclude text 29 in the merged output.
    part_29optSTRINGText part 29.
    enabled_30optBOOLEANtrueInclude text 30 in the merged output.
    part_30optSTRINGText part 30.
    enabled_31optBOOLEANtrueInclude text 31 in the merged output.
    part_31optSTRINGText part 31.
    enabled_32optBOOLEANtrueInclude text 32 in the merged output.
    part_32optSTRINGText part 32.

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGAll enabled text slots merged into one string.