Nodes/ComfyUI Mask Area Condition/Select Data based on Condition
ComfyUI Node

Select Data based on Condition

A plain if/else for ComfyUI wires

By a-und-b·Created about a year ago·Updated about a year ago· 5
Select Data based on Condition
  • data_if_true
  • data_if_false
  • selected_data
condition

ComfyUI doesn't have an if statement in its default vocabulary. You can build elaborate graphs, but a plain "depending on this boolean, hand me that thing" switch takes real contortion - math nodes, masks, manual bypasses. Select Data based on Condition is the missing branch: three inputs, one output, and it does exactly what you'd guess. It's the companion node to Mask Area Condition, but it's useful on its own whenever you want to pick between two values mid-graph.

The three inputs are:

  • data_if_true (any type)
  • data_if_false (any type)
  • condition (BOOLEAN)

One output: selected_data. If condition is True you get data_if_true; otherwise data_if_false. That's the whole node.

The detail that makes it work is the wildcard type. The * on those inputs and the output means the node accepts anything - images, latents, masks, strings, checkpoints, model objects, numbers. One selector handles a two-way choice between full latent pipelines just as happily as it picks between two text prompts. It's a generic switch, not a mask thing, which is why the README calls it a general-purpose helper.

The second quiet detail: condition is marked forceInput, so it's meant to come from a wire, not a widget you flip by hand. That's what makes it automatable - something upstream computes the boolean and the selector follows along.

Where people get burned: SelectData picks data, it does not skip work. ComfyUI executes nodes in dependency order and there's no lazy evaluation, so both data_if_true and data_if_false run their full upstream chains even though only one result is handed downstream. If you wire it as "big face → skip the detailer, small face → run the detailer," the detailer still executes on every image; you just ignore its output half the time. Use this node to route values - which checkpoint, which denoise, which prompt, which mask gets used - and save yourself the false promise of compute savings. (For actual skipping you'd need a bypass mechanism that honors the boolean, and this pack doesn't ship one.)

The natural pairing is with MaskAreaCondition from the same pack: that node's is_below_threshold plugs straight into condition, then data_if_true gets the "small face" path and data_if_false the "already fine" path. Since v1.1.0 the pack dropped its earlier gate nodes in favor of this one selector, which is the right call - one generic switch beats two narrow image/mask-specific ones.

Install it the same way as its sibling, because they ship in one repo: either ComfyUI Manager (search "Mask Area Condition") or

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/a-und-b/ComfyUI_MaskAreaCondition

then restart ComfyUI and reload the tab. No dependencies, no model downloads, pure torch. It shows up under mask → conditional, which undersells it a bit - it's a routing node, and routing is half of making a graph feel like a program instead of a diagram.

Categorymask/conditional

Inputs (3)

NameTypeDefaultDescription
data_if_true*
data_if_false*
conditionBOOLEAN

Outputs (1)

NameTypeDescription
selected_data*