Any String Switch
First connected prompt wins
- string
Any String Switch takes several STRING inputs and outputs the first one that's actually connected and live. Text is the one primitive type you can't see in a graph - a prompt buried inside a text-encode node is invisible until you open it - so having a typed node that is the current text, decided by slot order, is genuinely handy.
This is the fallback-switch pattern the community knows from rgthree's Any Switch: no selector, first non-null input wins. Tojioo's take is typed, so this node only ever carries strings, and the output socket is named string so there's no guessing about what's coming out.
How it works
One socket, text_1, to start; wire another text source and a text_2 slot grows. At run time it gathers every input that isn't None and returns the lowest-numbered connected one. The None skip is what makes it a fallback rather than a hard switch: mute or bypass the node feeding text_1 and its slot delivers None, gets skipped, and text_2 wins without you touching anything. Connect nothing at all and it errors with "no inputs connected" instead of silently emitting an empty string.
Like the other primitive switches here, STRING is a force-input type, so the sockets are wire-only - no text box to type into, which keeps every value provably sourced from somewhere in the graph.
Where you'd use it
- Prompt presets. Style A wired into
text_1, style B intotext_2; mute one and the other feeds the encoder. - Template fallbacks. A specialized prompt first, a generic fallback second, the graph decides.
- Feeding a prompt-extend or LLM node. Route between a fixed string and a generated one without re-wiring.
Install
ComfyUI Manager → search "Tojioo Passthrough" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Tojioo/tojioo_passthrough.git
Restart ComfyUI. No model downloads, no pip dependencies - the whole pack is Python plus a bundled frontend, and it's on the Comfy Registry under publisher tojioo.
Common issues
Slot order is the only rule that matters, so remember it's "first connected, lowest number" - not "last one I wired." If the wrong text flows, the earlier slot's upstream is muted or unwired, and muting is the intended way to switch. Also keep at least one slot connected; an empty switch raises an error rather than returning a blank string, which is honestly the friendlier failure mode.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text_1opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |