String Switch
Pick between two text values with one boolean
- STRING
String Switch answers a question that comes up constantly once your workflows get conditional: "depending on this boolean, use this text or that text." A prompt for the light version vs. the detailed version. A sampler name for quality vs. speed. A filename prefix for output A vs. output B. It's a two-position text selector, and it couldn't be more straightforward.
Three inputs, one output: boolean decides, on_true is what comes out when it's True, on_false when it's False. The default boolean value is True and both strings default to empty, so the node is instantly usable even before you wire a condition to it - you can just type the two texts and flip the toggle by hand. The output is a single STRING.
How it fits in a workflow
This is the "cheap" end of the pack's switch family. The heavy hitters - Input Switch, Signal Switch - route any type and, in the lazy variants, only evaluate the branch you take. String Switch does neither of those things, because it doesn't need to: the two branches are just text widgets sitting on the node. There's no expensive downstream graph attached to a string, so "lazy vs eager" is meaningless here. What it trades away in power it makes up in ergonomics - you see both strings on the node at once, and swapping is a boolean flip, not a rewiring.
The natural driver is any node that produces a boolean: String Compare, Number Compare, Is None, or the pack's boolean AND/OR gates. So a realistic chain looks like: String Compare checks whether the loaded filename contains "4k" → its BOOLEAN feeds String Switch → on_true is the 4k-friendly prompt, on_false is the standard one → the STRING output goes to a CLIP text encode. Two string values, one condition, zero rewiring.
It's also worth knowing this node is the manual, visible sibling of the pack's Combo Switch, which picks between dropdown options and also hands you the index and the raw string. If your two choices are really a menu of four, use Combo Switch instead.
Installing it
String Switch ships in Nifty Nodes for ComfyUI (Stibo/comfyui-nifty-nodes). ComfyUI Manager → search "Nifty Nodes" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes
Restart afterward. The pack is written against the v3 API (comfy_api.latest), so you need a current ComfyUI or nothing loads; there are no model files and no extra pip dependencies for this node.
Gotchas worth knowing
Because boolean defaults to True, a String Switch with nothing wired to boolean is not "off" - it's permanently returning on_true. If your workflow's condition isn't hooked up and you're getting the wrong text, that's almost always the cause. And while both text inputs are plain widgets, they're inputs in the schema, so a determined workflow can feed them from elsewhere. In practice you'll type both strings and drive only the boolean, which is exactly what the node was built for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| boolean | BOOLEAN | true | Determines which string value is returned. |
| on_true | STRING | Returned when boolean is True. | |
| on_false | STRING | Returned when boolean is False. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |