Nodes/MD Nodes/MD: Any Switch (Boolean)
ComfyUI Node

MD: Any Switch (Boolean)

A two-way switch that doesn't care what's on the wires

By MDMAchine·Created about a year ago·Updated 3 months ago· 15
MD: Any Switch (Boolean)
  • on_true
  • on_false
  • default_value
  • selected_output
conditionfalse
pass_throughfalse

Once your workflows grow past one happy path, you need routing: run the cheap draft route or the slow quality route, swap a model, pick a LoRA, all from one boolean. MD_AnySwitch is a two-way data router that accepts anything on either branch - images, models, latents, text, whatever - and passes one side through based on a condition.

The "Any" in the name is the point. ComfyUI's type system usually fights you when you try to switch arbitrary data types; this node's inputs are typed *, meaning any type is accepted on both on_true and on_false, and the output carries whatever type came through. It's the same convenience that makes "Anything Anywhere"-style nodes popular - and the same class of node the community has gently warned about turning workflows into spaghetti. Used for one clean A/B toggle it's great; used for 40 nested routes, future-you will hate past-you.

The inputs

  • condition - the routing signal. True routes to on_true, False to on_false. Wire this to a boolean source, a comparison, an LFO gate - anything that produces a true/false.
  • pass_through - a debug override that ignores condition and always outputs on_true. Handy for forcing a branch while you test the other half of a graph without disconnecting wires. Keep it off normally.
  • on_true / on_false - the two candidate values.
  • default_value - the safety net. If the selected branch isn't connected (null), the node outputs this instead of a crash. The tooltip is blunt about why it exists: "prevents workflow crashes from null outputs."

One output, selected_output, carrying whatever came through. Log lines in the console tell you which path was taken and the value type, which makes debugging a mistyped route much easier than staring at wires.

A genuinely useful pattern

A/B model testing: put your regular checkpoint and your experimental one on the two branches, drive condition from a boolean widget, and re-queue to flip. Same for prompt branches, CFG values, or upscale paths. Because it routes any type, one switch can sit at every fork in your graph and stay relevant.

Installing it

Part of MD Nodes (MDMAchine/ComfyUI_MD_Nodes). ComfyUI Manager → search MD_Nodes → Install, restart, or:

cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes
pip install -r requirements.txt

Restart ComfyUI. Python 3.10+, GPL v3, pure Python - no extra dependencies for this one.

Common issues

The predictable failure is a blank output on one branch: if the unselected side is unconnected and you didn't set default_value, the node passes through null and downstream nodes can choke. Set a fallback if either branch might be missing. And remember the routing is a straight pass-through - the node does no type coercion or conversion, so if a downstream node rejects what comes out, the mismatch was already there on the input wire. Debugging tip: read the console log line, it names the path taken and the type - it resolves more "why is this empty" mysteries than any amount of squinting at wires.

CategoryMD_Nodes/Logic

Inputs (5)

NameTypeDefaultDescription
conditionBOOLEANfalseROUTING SIGNAL • Purpose: Determines which input path to pass through. • Action: True routes to Path A. False routes to Path B.
pass_throughBOOLEANfalseDEBUG MODE • Purpose: Hard-overrides the logic gate. • Action: If True, ignores 'condition' and always outputs Path A. ⭐ Recommended: Keep False for normal operation.
on_trueopt*PATH A (True) • The value to output if condition is True.
on_falseopt*PATH B (False) • The value to output if condition is False.
default_valueopt*FALLBACK VALUE • Purpose: Output if the selected path is missing/unconnected. ⭐ Prevents workflow crashes from null outputs.

Outputs (1)

NameTypeDescription
selected_output*