Nodes/Basic data handling/continue if not empty
ComfyUI Node

continue if not empty

Stop the run instead of feeding the sampler nothing

By StableLlama·Created about a year ago·Updated 3 days ago· 49
continue if not empty
  • value
  • value
message

ComfyUI is relentlessly optimistic about empty data. A filter that matches nothing, a prompt list that didn't load, an LLM node that returned an empty string - none of that is an error, so the graph cheerfully marches on and dies somewhere downstream, usually with a traceback that points at the innocent node. continue if not empty is the circuit breaker for that. You hand it a value; if the value is empty, the run stops right there instead of handing nothing to something that can't survive it.

What it's actually doing

The whole trick is one engine detail. Normally when you wire a data list into a node, ComfyUI slices it and runs that node once per item - five prompts in, five runs. That's exactly why an empty list is fatal: zero items means zero runs, and ComfyUI's list-mapping breaks on an empty input. This node declares INPUT_IS_LIST, so ComfyUI hands it the raw value instead of slicing, runs it once, and lets it decide.

Then the decision is a plain Python falsiness test. Empty means None, [], {}, set(), "", 0 or False. Empty returns an execution blocker - the engine's "don't run anything downstream of me" signal - and non-empty passes the value through untouched. Because the output is declared as a list, a single value gets wrapped in a one-item list on the way out, which is what keeps the node immune to the very crash it's guarding against.

Worth knowing what "blocked" looks like: the branch stops, the graph finishes, and whatever save or preview node was downstream of it never fires. Nothing lands in your output folder. That's the feature, and it's also why the silent default confuses people.

The two inputs

value (required, type *) is the thing you're guarding. It's a wildcard socket, so it takes anything. If it's falsy, the run stops.

message (optional, STRING, empty by default) is the author's own escape hatch: leave it blank for silent operation, or type something like no prompts left and that text is what ComfyUI shows when the flow is blocked. Set it. A workflow that just stops with no output is indistinguishable from a workflow that's broken.

The single output, value (type *), is also flagged as a list. Wire it into the node you're protecting - the sampler, the API node, the first node of the branch that can't handle emptiness.

Where it earns its place

The classic case is a batch job. You've built a 200-prompt list, run it through filter, and on some runs the filter matches nothing. Without a guard you get a crash mid-queue; with one, the job stops cleanly. Same story inside a loop body, or in front of an LLM/enhancer node where an empty response would otherwise send an empty prompt into a paid API or generate a lovely picture of nothing.

Understand what this node is not. rgthree's Any Switch is the opposite instinct - it picks the first non-empty input and keeps going, plan B style. continue if not empty doesn't substitute anything, it stops the pipeline. If you have a fallback, use a switch. If the honest answer is "there's nothing to do, don't do it", this is the node.

Installing it

No dependencies, no models - the pack is pure Python and its pyproject.toml declares an empty dependency list, so this installs in seconds. In ComfyUI Manager, search for Basic data handling, install, restart ComfyUI. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
# restart ComfyUI

You'll find it under the node menu's Basic/flow control category, and the display name is lowercase - continue if not empty - so searching the pack name is usually faster than typing the label. The pack is GPL-3.0, sits at around 49 stars, and StableLlama ships releases often; this node, plus the two JSON ones, arrived together in 2.0.0 in September 2026. If you can't find it, update the pack rather than assuming it doesn't exist.

Where people get burned

It blocks on values you meant. 0 is empty. False is empty. If you point this at a counter, a seed of 0, or a boolean, it will stop your run and look broken while doing exactly what it says. Non-strings are the trap; the string "0" is non-empty text and sails through, the integer 0 does not. When a guard fires constantly, put the pack's length node upstream first and see what you're actually holding.

The output runs per item. Because the output is a list type, everything downstream of it is list-mapped. That is deliberate and normally what you want, but it means a guard sitting mid-graph changes how the next node executes.

Conditional nodes in this pack have drawn frontend reports. If a control-flow node here ever seems to ignore its input - one early-2026 r/comfyui thread had the pack's if/else permanently choose the false branch - the community's fixes were the Nodes 2.0 frontend and the primitive feeding the condition, not the pack's logic. Turn Nodes 2.0 off and try a different boolean source before you file anything.

CategoryBasic/flow control

Inputs (2)

NameTypeDefaultDescription
value*The value to guard; execution is blocked when the value is empty.
messageoptSTRINGOptional message shown when the flow is blocked. Leave empty for silent operation.

Outputs (1)

NameTypeDescription
value*The input value, or an execution blocker when the value is empty.