ZF Multi Text Switch
A text router that only evaluates the route you picked
- text
- selected_index
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
selectedfield going out of sync withinput_count. If you dropinput_countbelow 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.
Inputs (34)
| Name | Type | Default | Description |
|---|---|---|---|
| input_count | INT | 41–32 | Number of visible text routes (1-32). |
| selected | INT | 10–32 | Active route. 0 is an explicit empty-text output; the node UI stores this value through its route buttons. |
| text_1opt | STRING | Text route 1. Only this route executes when selected. | |
| text_2opt | STRING | Text route 2. Only this route executes when selected. | |
| text_3opt | STRING | Text route 3. Only this route executes when selected. | |
| text_4opt | STRING | Text route 4. Only this route executes when selected. | |
| text_5opt | STRING | Text route 5. Only this route executes when selected. | |
| text_6opt | STRING | Text route 6. Only this route executes when selected. | |
| text_7opt | STRING | Text route 7. Only this route executes when selected. | |
| text_8opt | STRING | Text route 8. Only this route executes when selected. | |
| text_9opt | STRING | Text route 9. Only this route executes when selected. | |
| text_10opt | STRING | Text route 10. Only this route executes when selected. | |
| text_11opt | STRING | Text route 11. Only this route executes when selected. | |
| text_12opt | STRING | Text route 12. Only this route executes when selected. | |
| text_13opt | STRING | Text route 13. Only this route executes when selected. | |
| text_14opt | STRING | Text route 14. Only this route executes when selected. | |
| text_15opt | STRING | Text route 15. Only this route executes when selected. | |
| text_16opt | STRING | Text route 16. Only this route executes when selected. | |
| text_17opt | STRING | Text route 17. Only this route executes when selected. | |
| text_18opt | STRING | Text route 18. Only this route executes when selected. | |
| text_19opt | STRING | Text route 19. Only this route executes when selected. | |
| text_20opt | STRING | Text route 20. Only this route executes when selected. | |
| text_21opt | STRING | Text route 21. Only this route executes when selected. | |
| text_22opt | STRING | Text route 22. Only this route executes when selected. | |
| text_23opt | STRING | Text route 23. Only this route executes when selected. | |
| text_24opt | STRING | Text route 24. Only this route executes when selected. | |
| text_25opt | STRING | Text route 25. Only this route executes when selected. | |
| text_26opt | STRING | Text route 26. Only this route executes when selected. | |
| text_27opt | STRING | Text route 27. Only this route executes when selected. | |
| text_28opt | STRING | Text route 28. Only this route executes when selected. | |
| text_29opt | STRING | Text route 29. Only this route executes when selected. | |
| text_30opt | STRING | Text route 30. Only this route executes when selected. | |
| text_31opt | STRING | Text route 31. Only this route executes when selected. | |
| text_32opt | STRING | Text route 32. Only this route executes when selected. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| selected_index | INT | — |