Nodes/ComfyUI-My-Nodes/选择输出器
ComfyUI Node

选择输出器

One boolean, two inputs, one output

By Tagbliton·Created 2 years ago·Updated about a year ago· 11
选择输出器
  • if_True
  • if_False
  • anything
booltrue

Some nodes earn their keep by being clever. This one earns its keep by being dumb in exactly the right way. It takes a boolean, and depending on whether it's true or false, passes through one of two any-type inputs. One output comes out: anything, which is either if_True or if_False. That's the entire node, and it's exactly what you want when you need a manual or computed toggle in a workflow and nothing fancier.

The plumbing-layer story from the KB fits it perfectly: these switch nodes exist to fight repetition and illegibility - you have two candidate values (two prompts, two seeds, two checkpoint names) and you want one line of logic to pick between them. The bool input is where the decision comes from. It defaults to True as a widget, but the real power is converting it to an input and driving it from something else - a comparator's boolean output, a control signal from the pack's "比较分流器", or a value from another node's logic. Then the selector becomes the output gate of a conditional branch.

How it behaves, from the source: bool == True → pass if_True; bool == False → pass if_False; and if the bool is anything else (e.g. None or an unexpected type), it defaults to passing if_True. That last quirk is the only surprise: it fails open to the true branch, which is usually what you want for a "default path" design but worth knowing if you're passing a possibly-null boolean.

Where does it differ from its sibling "比较分流器" (Digital Comparator)? That node does a comparison and routes both branches. This one takes a ready-made boolean and routes just one output. If you already have a boolean, this is the cleaner tool; if you're starting from two values that need comparing, use the comparator.

Practical uses: switch between a positive and a fallback prompt, choose a checkpoint or LoRA by condition, route different latents into a sampler, or pick between two seeds when a condition is met. Because if_True/if_False/anything are all * (any type), it works with images, latents, strings, numbers - whatever you feed in comes back out.

Install: it ships in ComfyUI-My-Nodes - ComfyUI Manager → search "ComfyUI-My-Nodes", or git clone https://github.com/Tagbliton/ComfyUI-My-Nodes into custom_nodes and restart. No API key, no network dependency, no DashScope account nonsense - it's a pure local utility.

Gotchas. Two things. First, the fail-open-to-true behavior above - if a boolean arrives as None, you get if_True, silently. Second, ComfyUI's *-typed sockets can be finicky about what they accept from strongly-typed nodes; if a link won't snap, check the type of what you're feeding in rather than assuming the node is broken. And that's honestly it - there's not much else to get wrong with a three-wire switch.

Category我的节点/Tools

Inputs (3)

NameTypeDefaultDescription
booloptBOOLEANtrue
if_Trueopt*
if_Falseopt*

Outputs (1)

NameTypeDescription
anything*