Nodes/ComfyUI Layer Style/LayerUtility: If
ComfyUI Node Runs on cloud

LayerUtility: If

If — pick one of two values based on a condition

By chflame163·Created 3 years ago·Updated 5 days ago· 3,113
LayerUtility: If
  • if_condition
  • when_TRUE
  • when_FALSE
  • ?

A ternary, as a node. You give it a condition and two values - one for when the condition is true, one for when it's false - and it passes the matching one through. That's it. It's the building block for "do this or that depending on something upstream," and because its ports are wildcard-typed, it works on whatever you throw at it: an image, a mask, a number, a string, a model.

You reach for it when a workflow needs to fork on a value: use image A if a toggle is on, image B if it's off; pass a high denoise or a low one depending on a flag; route different conditioning based on a switch. It keeps a branch in one graph instead of maintaining two.

How it works

It evaluates if_condition for truthiness and outputs when_TRUE or when_FALSE accordingly. All three ports are the ComfyUI wildcard type (*), so the node doesn't care what kind of data it's routing - the output type simply follows whichever input it selected. Small aside worth knowing: the internal class name literally has a trailing space (LayerUtility: If ), a quirk baked into the pack. Doesn't affect use, but if you ever match on the class name in a script, that's why your exact-match fails.

The inputs and outputs that matter

  • if_condition (*) - the thing being tested. Wire in a boolean, a number, whatever produces the true/false you're switching on.
  • when_TRUE (*) - passed through if the condition is true.
  • when_FALSE (*) - passed through otherwise.

Output is a single wildcard port whose type matches the branch that won.

How to install it

Part of the LayerStyle pack. Via ComfyUI Manager: search LayerStyle, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt

then restart. Find it under 😺dzNodes → LayerUtility → Data. No model download.

Common issues & troubleshooting

It doesn't save you compute. This is the big one people expect wrong. Both when_TRUE and when_FALSE are wired as inputs, and ComfyUI generally resolves upstream nodes before this one runs - so both branches typically execute, and then the node just picks the winner. Use it to choose a value, not to skip an expensive path. If you need to genuinely bypass work, that's a different mechanism (muting/bypassing nodes, or a lazy-eval switch).

Type mismatch downstream. Because the output is a wildcard, the node it feeds might complain until it knows the concrete type. Make sure both branches carry the same type so whichever wins connects cleanly.

Condition never flips. Whatever you fed if_condition isn't changing truthiness the way you think. Preview the value upstream to confirm it's actually going true/false.

Node's not in the menu. The LayerStyle pack failed to import - usually a broken transformers dependency (a stray TensorFlow) taking the whole pack down on load. Read the traceback, use "Try Fix," or repair the library.

Category😺dzNodes/LayerUtility/Data

Inputs (3)

NameTypeDefaultDescription
if_condition*—
when_TRUE*—
when_FALSE*—

Outputs (1)

NameTypeDescription
?*—