Nodes/FlowNodes/πŸ”€ Boolean Switch expression
ComfyUI Node

πŸ”€ Boolean Switch expression

A boolean that picks between two values β€” the graph's if/else

By gitmyloΒ·Created 2 years agoΒ·Updated about a year agoΒ· 13
πŸ”€ Boolean Switch expression
  • Flow
  • True
  • False
  • Result
β—„Valueβ€”β–Ί

The name overexplains it. This is a two-position switch: a boolean decides which of two inputs gets passed through to the output. Flip the toggle and the graph routes down a different branch. Every serious workflow ends up needing one, and this is FlowNodes' take on it.

Where it beats the alternatives: most "switch" nodes in other packs are selector nodes that need an index or a name. This one just wants a boolean, and it lets the two candidate values be anything - a model, a latent, a string, a conditioning, an image. The sockets are typed * (ComfyUI's wildcard "any"), so it routes whatever you hand it with no conversion. Wire your boolean into Value, connect the two candidates to True and False, and Result is whichever one matched.

The gotcha that bites everyone

Here's the part the README doesn't shout about and the code reveals: the node does kwargs["True"] if Value else kwargs["False"], and unconnected optional inputs simply aren't in kwargs. So if you set Value to False but never wired anything into the False socket, you get a KeyError and the run dies.

Rule of thumb: connect both branches, even if one of them is just a dummy value. This node is built for A/B routing where both sides are live. If you genuinely only have one value and want a fallback when the boolean is off, this isn't the node - you want the "if the value exists, use it" pattern instead (rgthree's Any Switch is the classic for that). Different shape, different job: this one is a manual valve, not a fallback.

Wiring it into a real workflow

The classic use: two prompt styles, one toggle. Build prompt A and prompt B into two strings, feed both in, and flip a boolean from a Primitive or a converted widget to choose which reaches your text encoder. Or route two different samplers and pick between them without swapping cables around.

  • Value - the BOOLEAN selector. Source it from a Compare node, a checkbox, or even another switch.
  • True / False - the candidates. Both optional, both *, both should be connected.
  • Flow - an optional FLOW input. This is FlowNodes' ordering mechanism: connect a flow wire here to force this node to run at a specific point in the sequence (see the Flow start node for how flows work).

Output: Result, a * wildcard, so it feeds any socket downstream. And because FlowNodes' switches don't emit the "inactive" output as None - they emit the other value - you don't get the None-into-required-input crash that the If condition node is known for.

Install

Part of the FlowNodes pack. ComfyUI Manager β†’ search FlowNodes β†’ install β†’ restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/gitmylo/FlowNodes
# restart ComfyUI

No Python dependencies, no models, nothing to download. The pack is WIP and young - the switch logic itself is a couple of lines, but if the dynamic socket styling misbehaves, that's a GitHub-issue thing.

Troubleshooting

  • KeyError: 'False' - the branch you're switching to isn't connected. Wire it.
  • Result silently empty - the Value boolean is unwired and defaults to False, so you're always taking the False branch. Check the wire, not the node.
  • Want to flip which side is "on"? Toggle the boolean's polarity (or drop a Boolean Not in front of Value) rather than rewiring the branches.
CategoryπŸ”‚ FlowNodes/conditions

Inputs (4)

NameTypeDefaultDescription
ValueBOOLEANβ€”
FlowoptFLOWβ€”
Trueopt*β€”
Falseopt*β€”

Outputs (1)

NameTypeDescription
Result*β€”