Nodes/comfyui-easyapi-nodes/IsNoneOrEmptyOptional
ComfyUI Node

IsNoneOrEmptyOptional

IsNoneOrEmptyOptional – ComfyUI Node

By lldacing·Created 3 years ago·Updated 8 months ago· 96
IsNoneOrEmptyOptional
  • any
  • default
  • any

What it is

IsNoneOrEmptyOptional takes the same emptiness check as this pack's IsNoneOrEmpty - catching None, an empty list, an empty or whitespace-only string, or an empty dict - and instead of just telling you yes-or-no, it does something more directly useful: if the value is empty, it hands back a default value you provide instead; if it's not empty, it passes your original value straight through. It's a fallback node, not a check node. You get one output either way, and it's always something usable rather than a boolean you then have to branch on separately.

The README's own framing calls this lazy evaluation, and that's worth taking literally - the default isn't computed unless it's actually needed. That matters if computing your fallback value is itself expensive (loading something, running another node's worth of work): with a naive "compute both branches and pick one" approach you'd pay that cost every time regardless of whether the real value was already fine, whereas this node only reaches for the default when the input genuinely turns out empty.

Inputs and outputs

  • any (type *, required) - the value to check.
  • default (type *, optional) - what to return if any turns out to be empty by the same rules as IsNoneOrEmpty (None, empty list, empty/whitespace string, empty dict).

One output: any (type *) - your original value if it wasn't empty, otherwise default.

How it works

Same emptiness definition as its sibling node, IsNoneOrEmpty - this is genuinely the same check with a different output shape, not a separate rule. Wherever you'd otherwise write "if this is empty, use that instead" as an IsNoneOrEmpty boolean feeding into a conditional/switch node, this node collapses that into one step.

Installing it

Part of comfyui-easyapi-nodes. Through ComfyUI Manager: search "comfyui-easyapi-nodes", install, restart ComfyUI. Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt

No special dependency for this node itself, but running the requirements install keeps the rest of the pack from half-failing on load. git pull in the folder to upgrade later.

Common issues

"I left default unset and got an unexpected result when the input was empty." default is optional, so if you don't wire anything into it and the input turns out empty, think through what an unset optional input resolves to in your case before relying on it - it's safer to always wire an explicit fallback (even something as simple as an empty string or a zero) than to leave it unset and assume a particular behavior.

"This feels redundant with a Switch/If node I already have." For the specific case of "use this value, or fall back to a default if it's empty" - that exact pattern - this node is simpler than wiring a boolean check into a generic switch, because it collapses the check and the branch into one node instead of two. For more general branching logic (not specifically about emptiness), a dedicated switch/if node is still the right tool.

"How do I just get a true/false instead of a substituted value?" That's the plain IsNoneOrEmpty node - same underlying emptiness rule, but it returns the boolean itself rather than picking between your value and a default.

CategoryEasyApi/Utils

Inputs (2)

NameTypeDefaultDescription
any*
defaultopt*

Outputs (1)

NameTypeDescription
any*