Stop If
Kill a run mid-graph when a condition goes true
- flow
- dependency
- flow
A conditional halt for your graph - wire this into a chain, feed it a condition, and when that condition flips true the run stops there instead of continuing downstream. It's part of a small "workflow control" family inside JNComfy (jn-jairo/jn_comfyui) that brings sequencing concepts most people only think about in real programming languages - do this, then that, unless X - into ComfyUI's node graph.
Why this exists
ComfyUI executes nodes based on data dependencies, not the order you dragged them onto the canvas - it's a scheduler, not a script. There's no native "stop the whole run here if something's wrong" primitive. If you want that behavior - bail out of a batch job early, skip an expensive downstream branch when an earlier check fails - you need a node that can actually interrupt execution, and this is JNComfy's version of it.
How it works
Everything on this node is optional, which is a little unusual - you're expected to wire in what you need. condition is the BOOLEAN gate (default false, meaning "don't stop" by default). title lets you label the check so it's identifiable if you've got several of these in one graph. The real mechanics are flow and dependency: this pack's nodes chain execution order manually by passing a generic *-typed token from one node's flow output into the next node's flow or dependency input, since ComfyUI otherwise has no guaranteed ordering between nodes that don't share real data. When condition evaluates true, the run halts at this point instead of continuing to whatever's wired to its flow output.
The inputs and outputs that matter
condition(BOOLEAN, defaultfalse) - feed this from JN_LogicOperation, JN_BooleanOperation, or a manual JN_PrimitiveBoolean. True stops the run here.title(STRING, default empty) - an optional label for this specific check, useful once you have more than one StopIf in a graph.flow(any type) - connect this from an upstream flow-chain node to enforce ordering.dependency(any type) - an alternate way to force this node to wait on something else finishing first.
The single output, flow, only fires if the condition didn't trigger a stop - wire it into the next node's flow/dependency input to continue the chain.
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 with essentially no public discussion anywhere we could find, and no entry in our knowledge base - the "flow chaining" pattern this node family uses isn't a documented ComfyUI convention either, so if you're new to it, treat this article and its siblings (JN_Flow, JN_FlowOutput, JN_Condition) as your reference rather than searching for prior art.
Common issues & troubleshooting
Nothing seems to stop, condition or not. If you never wired flow/dependency into or out of this node, ComfyUI has no reason to run it in any particular order relative to the rest of your graph - the condition check itself still evaluates, but "stopping the run" only means something if this node's position in the execution order actually matters. Make sure you've chained it in properly.
The whole branch gets skipped even when condition is false. Remember ComfyUI prunes any node that isn't (directly or transitively) connected to something that actually executes - an output node, a save, or one of this pack's terminal nodes like JN_FlowOutput. If your chain dead-ends without reaching one of those, the entire branch, StopIf included, may simply never run.
You want to halt unconditionally, not on a condition. Just wire condition to a JN_PrimitiveBoolean set to true, or skip this node entirely and just not connect the downstream branch.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| conditionopt | BOOLEAN | false | — |
| titleopt | STRING | — | |
| flowopt | * | — | |
| dependencyopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| flow | * | — |