Nodes/ZF-ComfyUI-Helper/ZF Multi Text Switch
ComfyUI Node

ZF Multi Text Switch

A text router that only evaluates the route you picked

By Z-yaofang·Created 2 months ago·Updated 19 days ago· 1
ZF Multi Text Switch
    • text
    • selected_index
    input_count4
    selected1
    text_1
    text_2
    text_3
    text_4
    text_5
    text_6
    text_7
    text_8
    text_9
    text_10
    text_11
    text_12
    text_13
    text_14
    text_15
    text_16
    text_17
    text_18
    text_19
    text_20
    text_21
    text_22
    text_23
    text_24
    text_25
    text_26
    text_27
    text_28
    text_29
    text_30
    text_31
    text_32

    Every serious ComfyUI workflow eventually needs "I have four different positive prompts and I want to flip between them with one click." The built-in answer is a primitive value node per prompt and a lot of rewiring. ZFMultiTextSwitch (display name "ZF Multi Text Switch") is the clean version: one node, up to 32 text routes, one button per route, and a single text output that carries whichever route you selected.

    It's part of ZF-ComfyUI-Helper, the no-dependency utility pack, and it lives under ZF Helper/Text.

    How it behaves - and the design choices that matter

    Two inputs drive everything:

    • input_count - how many text inputs to show (1–32, default 4).
    • selected - which route is active. The route buttons in the node's UI set this for you, so you mostly never touch the number directly.

    The interesting part is how it routes. Unlike a first-non-null switch (rgthree's Any Switch walks inputs and picks the first non-empty one), this is an explicit A/B-style selector with lazy evaluation: only the selected route is actually executed. The node tells ComfyUI which upstream input it needs and the others don't run at all - which means you can hang expensive upstream text-processing on unselected routes without paying for them.

    There is deliberately no content-based fallback. Select route 2 and route 2 is empty, you get an empty string, not a silent "let me try route 1 anyway." That's a feature if you've ever been burned by a switch guessing wrong; it's a gotcha if you assumed graceful fallback. The one special case is the dedicated Empty Text button: selecting it outputs "" with route index 0, which is the explicit "intentionally empty" route.

    Outputs

    Two, both useful: text (the selected route's string) and selected_index (an INT reporting which route was picked - handy if you're logging or driving other logic off the selection). Wire text into a CLIP Text Encode, a save node, or anywhere else a string goes.

    Installing it

    Same trivial install as the rest of the pack - no dependencies at all:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Z-yaofang/ZF-ComfyUI-Helper
    

    Restart ComfyUI, or install via ComfyUI Manager by searching ZF-ComfyUI-Helper. No models, no requirements.txt.

    Where people trip

    • Thinking it falls back. It doesn't, and that's documented. If a route looks empty when you expected content, check that you connected that specific route, not that the node is being helpful. Unconnected or empty routes output "".
    • The selected field going out of sync with input_count. If you drop input_count below the route you had selected, the node clamps to the visible range - you won't error, but you may silently be on a different route than you think.
    • Expecting one output per route. It's one text output that mirrors the selection, not 32 parallel outputs. That's the point, but it surprises people coming from "one node per prompt."

    The lazy-evaluation detail is the reason to reach for this over a home-built pile of Primitive nodes: when you scale to 8–16 prompts with heavy conditioning upstream, "only run what's selected" stops being a nicety and starts being the difference between a snappy workflow and one that recomputes everything every run.

    CategoryZF Helper/Text

    Inputs (34)

    NameTypeDefaultDescription
    input_countINT41–32Number of visible text routes (1-32).
    selectedINT10–32Active route. 0 is an explicit empty-text output; the node UI stores this value through its route buttons.
    text_1optSTRINGText route 1. Only this route executes when selected.
    text_2optSTRINGText route 2. Only this route executes when selected.
    text_3optSTRINGText route 3. Only this route executes when selected.
    text_4optSTRINGText route 4. Only this route executes when selected.
    text_5optSTRINGText route 5. Only this route executes when selected.
    text_6optSTRINGText route 6. Only this route executes when selected.
    text_7optSTRINGText route 7. Only this route executes when selected.
    text_8optSTRINGText route 8. Only this route executes when selected.
    text_9optSTRINGText route 9. Only this route executes when selected.
    text_10optSTRINGText route 10. Only this route executes when selected.
    text_11optSTRINGText route 11. Only this route executes when selected.
    text_12optSTRINGText route 12. Only this route executes when selected.
    text_13optSTRINGText route 13. Only this route executes when selected.
    text_14optSTRINGText route 14. Only this route executes when selected.
    text_15optSTRINGText route 15. Only this route executes when selected.
    text_16optSTRINGText route 16. Only this route executes when selected.
    text_17optSTRINGText route 17. Only this route executes when selected.
    text_18optSTRINGText route 18. Only this route executes when selected.
    text_19optSTRINGText route 19. Only this route executes when selected.
    text_20optSTRINGText route 20. Only this route executes when selected.
    text_21optSTRINGText route 21. Only this route executes when selected.
    text_22optSTRINGText route 22. Only this route executes when selected.
    text_23optSTRINGText route 23. Only this route executes when selected.
    text_24optSTRINGText route 24. Only this route executes when selected.
    text_25optSTRINGText route 25. Only this route executes when selected.
    text_26optSTRINGText route 26. Only this route executes when selected.
    text_27optSTRINGText route 27. Only this route executes when selected.
    text_28optSTRINGText route 28. Only this route executes when selected.
    text_29optSTRINGText route 29. Only this route executes when selected.
    text_30optSTRINGText route 30. Only this route executes when selected.
    text_31optSTRINGText route 31. Only this route executes when selected.
    text_32optSTRINGText route 32. Only this route executes when selected.

    Outputs (2)

    NameTypeDescription
    textSTRING
    selected_indexINT