Nodes/Nifty Nodes for ComfyUI/None Input Switch
ComfyUI Node

None Input Switch

Pick a fallback when an optional input is actually None

By Stibo·Created 5 months ago·Updated 2 months ago· 9
None Input Switch
  • on_exists
  • on_none
  • value
  • output

ComfyUI is full of nodes where "nothing is connected" is a legitimate state - a loader set to none, an optional ControlNet you didn't wire up, a conditional branch that produced no output. Most of the time a missing value just breaks the graph. None Input Switch is the polite bouncer: it looks at a value, and routes to one of two branches depending on whether that value is None or actually exists.

What it is

A logic node from the Nifty Nodes pack's switch family. Three inputs, one output:

  • value - the thing to check.
  • on_exists - passed through when value is not None.
  • on_none - passed through when value is None.
  • Output: output - whichever branch won.

So the pattern is: connect your possibly-empty upstream output to value, connect your real pipeline to on_exists, connect your fallback to on_none, and downstream always has something sensible to work with. A classic use: an optional reference image branch. When a reference image exists, use it; when it doesn't (the loader was set to none), fall back to a placeholder or bypass the whole feature.

Lazy vs eager - why this matters

This version is lazy, which is the detail that makes it interesting. The node only evaluates the branch that's actually selected - if value is None, on_none runs and on_exists is never executed. In ComfyUI terms, the unselected branch's upstream nodes don't run at all.

That's a real performance and correctness win: it means you can hang an expensive subgraph (a whole second sampler, say) off the on_exists branch, and when the check fails, that work simply doesn't happen. It also means the node needs to know which branch to pick before deciding - the lazy status check is what drives that.

The trade-off: lazy evaluation means the node's behavior depends on the graph's evaluation order in subtle ways. If you ever need both branches to run no matter what (for side effects, caching, or because ComfyUI's lazy handling trips over your graph), that's what the None Input Switch (Eager) variant is for.

Installing it

It ships with Nifty Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes

or search "Nifty Nodes" in ComfyUI Manager, then restart. No models, no extra dependencies.

Gotchas

Two things to keep straight. First, None here is a real Python None - an unconnected optional input also reads as None, which is usually what you want (it's how the "optional branch" trick works) but can surprise you if you expected an empty value instead. Second, remember this is the lazy variant: if your workflow depends on the on_exists branch running even when it isn't selected - say, to populate a preview - use the eager version instead. And as with the whole pack, it targets ComfyUI's newer V3 API, so keep ComfyUI updated if the node doesn't appear.

Categorynifty/logic

Inputs (3)

NameTypeDefaultDescription
on_existsoptCOMFY_MATCHTYPE_V3Value passed through when 'value' is not None. Only evaluated if selected (lazy).
on_noneoptCOMFY_MATCHTYPE_V3Value passed through when 'value' is None. Only evaluated if selected (lazy).
valueopt*The value to check. If it is None, on_none is used; otherwise on_exists.

Outputs (1)

NameTypeDescription
outputCOMFY_MATCHTYPE_V3