Nodes/OmniNodes/Conditional Gate 🚦
ComfyUI Node

Conditional Gate 🚦

One node that compares, decides, and routes

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Conditional Gate 🚦
  • payload
  • output_true
  • output_false
  • condition_met
β—„value_a0β–Ί
β—„comparatorβ–Ύβ–Ί
β—„value_b0β–Ί

Most "if this, then that" setups in ComfyUI need two nodes: a comparison node to produce a boolean, and a switch node to route based on it. Conditional Gate collapses both into one - it compares two values, decides, and pushes your payload down a true or false output. Fewer nodes, fewer wires, and a condition_met boolean you can grab for logging or branching.

It's squarely in the plumbing layer the KB maps out - the any-type switch family. The whole trick that makes it work is ComfyUI's wildcard * type: a socket that accepts anything, from an IMAGE to a MODEL to a string. That's why one gate can route whatever you throw at it.

How it works

Two inputs, value_a and value_b, plus a comparator dropdown with ==, !=, >, >=, <, <=. It tries to parse both values as floats first; if both parse, it compares numerically. If either fails to parse, it falls back to string comparison - where only == and != are meaningful (the code explicitly returns False for > on a non-numeric string rather than doing something dumb with text).

Then the routing: if the condition holds, payload comes out of output_true and output_false receives None. If not, the reverse. That None-on-the-unused-socket behavior is the standard optional-input convention - you wire the branch you care about into a downstream optional input, and None simply means "not connected" to the node after it.

The inputs that matter

  • value_a / value_b - the things being compared. They're typed as STRING but compared numerically when possible, which is how a Batch Counter's INT index or a seed stepper's output flows in without conversion fuss.
  • comparator - the six standard operators.
  • payload - the any-type thing you want routed. This is the optional one; you can use the gate purely as a comparison-and-condition_met source and skip routing entirely.

Outputs

output_true and output_false - same type as your payload, one of them carrying None. Plus condition_met, a BOOLEAN that's useful on its own: feed it into a Workflow End's run label, or into a log node, without needing a second gate.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes

Restart ComfyUI; find Conditional Gate 🚦 under TensorVizion/Workflow. No extra dependencies.

Where people get burned

  • The untaken output is None, not empty. Wire it into a required input and ComfyUI may complain or behave oddly. None belongs in optional inputs downstream - that's the contract the whole pack's switch family relies on.
  • String > silently returns False. If you compare two non-numeric strings with > expecting alphabetical ordering, you'll get a constant false. Use ==/!= for strings.
  • It doesn't type-check. Because the sockets are *, ComfyUI won't warn you if you wire a MODEL where you meant an IMAGE - the gate passes whatever it's given through blindly. That's the price of one node doing the job of two.

The pair worth knowing: Conditional Gate feeding a downstream optional input is the pack's branching story. Combined with Batch Counter for the "every N runs" case, you can build real control flow - if, else, and a boolean you can log - without leaving the graph.

CategoryTensorVizion/Workflow

Inputs (4)

NameTypeDefaultDescription
value_aSTRING0β€”
comparatorCOMBO6 options: ==, !=, >, >=, <, <=
value_bSTRING0β€”
payloadopt*β€”

Outputs (3)

NameTypeDescription
output_true*β€”
output_false*β€”
condition_metBOOLEANβ€”