Nodes/JNComfy/First Active
ComfyUI Node

First Active

Give it several maybe-empty inputs, get back the first real one

By jn-jairo·Created 2 years ago·Updated 2 years ago· 5
First Active
  • values
  • *
merge_array_itemstrue

This is ComfyUI's version of a coalesce: you've got two or three possible sources for a value - a translated prompt if one exists, otherwise the original; an override if the user set one, otherwise a default - and you want whichever one is actually there, without a pile of conditional nodes to figure it out.

It ships in JNComfy (jn-jairo/jn_comfyui), a solo-maintained pack that's mostly invisible outside its own README - there's essentially no community discussion of it anywhere, which is normal for a personal toolkit rather than a project built for an audience. What it lacks in visibility it makes up for in breadth: alongside JN_FirstActive, the same "Primitive > Process" family includes math reducers, key-value tagging, and array utilities that all lean on the same underlying tricks.

How it works

The mechanism only makes sense once you know about one of the pack's own patches, documented right in the README: "Easy multiple inputs." Normally a ComfyUI input socket takes exactly one wire. JNComfy patches that so any socket marked multiple can take as many wires as you connect, arriving as a list. That's what values is - connect two, five, however many candidate sources you have, and JN_FirstActive walks through them in the order you wired them and returns the first one that's actually present (not empty, not disconnected, not None).

merge_array_items (on by default) matters when one of your candidates is itself an array rather than a single value: with it on, the node looks inside that array for the first active item rather than treating the whole array as one lump candidate. Since an array is always "there" once it exists, leaving this off would mean an array candidate basically always wins outright the moment it's reached - which is rarely what you want, so the default makes sense for most cases.

The inputs and outputs that matter

  • merge_array_items (required, boolean, defaults on) - look inside array candidates instead of treating them as one unit.
  • values (optional, any type, multiple) - your candidate sources, checked in wiring order.
  • Output: a single value of whatever type actually won.

Installing it

ComfyUI Manager: search "JNComfy". Manual:

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

Restart ComfyUI. No models, no extra dependencies - it's a pure logic node.

Common issues & troubleshooting

The wrong candidate keeps winning. Order matters - the node returns the first active value, so your fallback needs to be wired last, not first. If you're getting the "wrong" answer, check the actual order of connections on the values socket rather than assuming priority is inferred some other way.

A deliberate 0 or empty string gets skipped. "Active" here almost certainly follows ordinary truthiness - 0, "", None, and empty lists all read as "not there." That's usually what you want for a fallback pattern, but it's a real trap if one of your candidates is a legitimately meaningful zero. Wire a JN_Dump onto the output before trusting this in anything load-bearing if that's a possibility for your graph.

Nothing was active, and now something downstream errors. This node doesn't manufacture a value out of nothing - if every candidate was empty, whatever consumes the output needs to handle that itself, or you need a hard default as the last wire in the chain rather than assuming JN_FirstActive will invent one.

CategoryJN/Primitive/Process

Inputs (2)

NameTypeDefaultDescription
merge_array_itemsBOOLEANtrue
valuesopt*

Outputs (1)

NameTypeDescription
**