Text Switch
A boolean switch for text, which is harder than it sounds
- str
Sometimes you want a chunk of text in the pipeline only some of the time - a quality tag that's in your prompt for "high quality" runs but out for experiment runs, a negative phrase you toggle, a metadata field you include conditionally. Text Switch is the two-line answer: a boolean active input decides whether a string passes through, or comes out empty.
How it works
Two inputs: str (the text to conditionally pass through, multiline) and active (a boolean, default true). One output: str. If active is true, you get your text back exactly; if false, you get an empty string. That's the entire node, and honestly that's all it should be - the value is in what you can wire the boolean to.
The active input is force-input, which is the point: instead of clicking the toggle by hand, you can drive it from anything that produces a boolean - a batch counter, a comparison node, a control node, another workflow's state. That's what turns a trivial node into a real one. Hand-toggle it and it's a bypass; wire it and it becomes conditional logic in your graph.
Why this beats muting or deleting
If you've built the same workflow both ways, you know: muting a node in ComfyUI is a manual action that doesn't survive workflow-share contexts well, and deleting/re-adding text is fiddly. A switch node makes the inclusion of text data - reproducible, wireable, and visible in the graph. It's the text-flavored cousin of the pack's general Switch node, just typed for strings. And for metadata work specifically, it's handy: toggle a piece of metadata text on and off without rewriting the metadata assembly.
Installing it
Part of the Sage Utils pack - ComfyUI Manager (search Sage Utils) or:
cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils
cd ComfyUI_SageUtils
pip install -r requirements.txt
Restart ComfyUI. Only pip dependency is dynamicprompts; no model downloads.
The one thing to watch
It passes the text through or returns an empty string - it does not trim, transform, or default to something else. An empty string downstream can still be "a value" to nodes that treat empty and absent differently, so if your downstream node misbehaves when the switch is off, the empty string is probably the culprit. Also worth knowing: the default for active is true, so a fresh node passes text through until you tell it otherwise.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| str | STRING | Text to conditionally pass through. | |
| active | BOOLEAN | true | If true, passes the text through; otherwise returns an empty string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| str | STRING | Output value for str_out. |