ComfyUI Node

switch a and b

A two-way text switch driven by a real BOOL

By YMC-GitHub·Created 3 years ago·Updated about a year ago· 20
switch a and b
  • boolean
  • text
a
b

Routing is the other half of prompt automation: when a condition is true, use prompt A; otherwise, prompt B. Switch a and b is exactly that for strings - two text inputs, one BOOL input, one text output. true gives you a, false gives you b. It's the simplest possible conditional, and in a graph full of switch nodes, it's the one that takes a real boolean rather than a string pretending to be one.

Where you'll reach for it: an A/B test of two prompt styles flipped by a toggle, a "portrait vs landscape" selection driven by a resolution check, or swapping positive and negative fragments based on a workflow flag. Because the boolean input is a genuine BOOL socket, it wires cleanly into any node that emits a real boolean - no string parsing in the middle.

How it works

The exec method checks the boolean and returns a when it's True, b otherwise. There's no rounding, no string comparison, no hidden logic - it's a literal ternary. The one thing to remember is which way it leans: Truea, Falseb. If your workflow keeps picking the "wrong" side, that's the first thing to check.

Inputs and outputs

  • a - STRING, the True choice
  • b - STRING, the False choice
  • boolean - BOOL, the switch
  • Output: text - either a or b

Installing it

# ComfyUI Manager: search "ymc suite" and install ymc-node-suite-comfyui
# or:
cd ComfyUI/custom_nodes
git clone https://github.com/YMC-GitHub/ymc-node-suite-comfyui

Restart after installing. Dependencies are four small pure-Python PyPI helpers that self-install; no models, no GPU cost.

Gotchas

  • If your "boolean" only exists as text ("true", "1", "yes"), this node can't take it directly - that's what the sibling switch a and b (isRoundTo) is for, which compares two strings instead of a BOOL.
  • It's a stateless selector, not a toggle - it doesn't remember the last pick or alternate between runs. For alternating, pair it with the loop node's index output.
  • The WAS-conflict note applies here as with the whole pack: if WAS Node Suite is also installed, Manager may flag shared node names between the two packs - both have text switches, so pick a side if you see conflicts.
Categoryymc suite/text/plain

Inputs (3)

NameTypeDefaultDescription
aSTRING
bSTRING
booleanBOOL

Outputs (1)

NameTypeDescription
textSTRING