Nodes/JNComfy/Condition
ComfyUI Node

Condition

An if/else node for any two values

By jn-jairo·Created 2 years ago·Updated 2 years ago· 5
Condition
  • if_true
  • if_false
  • *
conditiontrue

A ternary, as a node - this thing, or that thing, picked by a boolean. If you've written a if condition else b in Python, JN_Condition is exactly that, wired into a ComfyUI graph. It's part of JNComfy (jn-jairo/jn_comfyui), and despite sitting in the pack's "Workflow" category alongside nodes like JN_Flow and JN_StopIf, it works differently from them - this one is a pure data selector, not part of the manual execution-ordering chain those nodes use.

Why you'd want it

Plenty of ComfyUI graphs need to pick between two values based on some condition - which of two models to load, which of two prompts to use, which processed image to send onward - without wanting a whole separate branch of the graph to actually run for the option you didn't pick. This node gives you that choice as a single, clean point rather than routing conditionally through separate downstream paths.

How it works

All three inputs are optional: condition (BOOLEAN, default true), if_true (any type), and if_false (any type). When condition is true, the node's output is whatever's wired into if_true; when false, it's if_false. Both value inputs are typed * - the generic wildcard this pack enables via its own patch to ComfyUI's input system - so you can pick between images, strings, numbers, or model objects, anything at all, as long as both sides are something the rest of your graph can accept once selected.

Notably, unlike JN_Flow/JN_StopIf/JN_Exec, this node has no flow or dependency inputs and isn't part of that manual sequencing family - it's evaluated through normal ComfyUI data-dependency scheduling, the same as any ordinary node.

The inputs and outputs that matter

  • condition (BOOLEAN, default true, optional) - the switch. Feed it from JN_LogicOperation, JN_BooleanOperation, or a manual JN_PrimitiveBoolean.
  • if_true (any type, optional) - what gets output when the condition is true.
  • if_false (any type, optional) - what gets output when the condition is false.

Output is a single *-typed value - whichever of the two you selected.

How to install it

Via ComfyUI Manager: search "JNComfy", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui

then restart ComfyUI. This is a small, single-author pack - no meaningful community discussion anywhere we could find, no entry in our knowledge base - so treat it as a solid personal-toolbox utility rather than something with community-sourced troubleshooting behind it.

Common issues & troubleshooting

Left the default condition = true and it's always picking if_true. Worth double-checking on a fresh node - the default here is true, not false, which is the opposite default from most of this pack's other boolean-driven nodes (JN_StopIf defaults to false). If you're wiring this into a graph and forgot to connect an actual condition, you'll silently always get if_true.

Both branches seem to execute regardless of which one gets output. This node selects between already-computed values - it doesn't prevent both if_true and if_false from being computed upstream if they're both wired in. If one of the two branches is expensive and you only want it to run when selected, this node alone won't skip that computation; you'd need to gate the branch itself with something like JN_StopIf instead.

Type mismatch downstream. Since the output is the generic * type, this node won't stop you from wiring an image on one side and a string on the other - if a downstream node then errors depending on which branch got picked, that's a real mismatch in your graph design, not a bug in this node.

CategoryJN/Workflow

Inputs (3)

NameTypeDefaultDescription
conditionoptBOOLEANtrue
if_trueopt*
if_falseopt*

Outputs (1)

NameTypeDescription
**