ComfyUI Node Runs on cloud

Logic node

Compare two values and branch your workflow

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Logic node
  • CompareValue_A
  • CompareValue_B
  • OnTrue
  • OnFalse
  • *
Operation

This is the closest thing Derfuu's pack has to an if statement. It compares two values with an operator you choose, and depending on whether that comparison is true or false, it passes through one of two other values. Think "if A > B, use this, otherwise use that." In a graph that normally just flows top to bottom, this is how you make a decision.

It's a "Functions" node in Derfuu_ComfyUI_ModdedNodes. The DF_ prefix is the pack's current naming; the same node appears as plain Logic node in older workflows, with slightly different operator labels.

How it works

You set an Operation, give it a value to compare (CompareValue_A, required), and optionally a second value plus the two outcomes:

  • Operation - one of A > B, A < B, A = B, A AND B, A OR B, A XOR B. The first three are comparisons; the last three are boolean logic.
  • CompareValue_A (required, wildcard *) and CompareValue_B (optional, *) - the two things being compared. The * type means it accepts anything - ints, floats, booleans, strings.
  • OnTrue (optional, *) and OnFalse (optional, *) - what gets passed out for each result.

The single output is a wildcard *, and here's the behavior straight from the pack's README: it "compares 2 values and returns one of 2 others (if not set - returns False)." So if you wire OnTrue/OnFalse, it emits one of those; if you leave them empty, it just emits the boolean result of the comparison.

Where you'd use it

Conditional routing. Say you want a different behavior when an input image is portrait vs landscape: compare its width and height with Get image size, and use OnTrue/OnFalse to select the value that steers the rest of the graph. Or gate on a computed number crossing a threshold. It's the node that lets a workflow react to its inputs instead of running the same path every time.

Honest scope: this is a value selector, not full control flow - it doesn't skip execution of a branch, it picks which value comes out. For genuine branching/muting of whole graph sections, people lean on rgthree's fast group bypassers or Impact Pack's switches. DF_Logic_node is for choosing a value; don't expect it to turn parts of the graph off.

Common issues & troubleshooting

It output False / a boolean, not my value. You didn't wire OnTrue/OnFalse. With those empty it returns the raw comparison result by design. Connect the two outcome inputs to pass real values.

Comparing incompatible types. The * ports accept anything, but comparing a string to a number won't do what you want. Make sure both compare values are the same kind.

Old Logic node (spaces) shows red. That's the pre-rename class, and its operators were labeled >, <, =, AND, OR, XOR. Derfuu deletes old classes on reorganizations rather than deprecating them, so old graphs break - replace it with this current DF_Logic_node.

ModuleNotFoundError: No module named 'custom_nodes.Derfuu_ComfyUI_ModdedNodes'. Old workflow, moved module path. Update the pack, reload, swap the node.

Install: ComfyUI Manager → search "Derfuu" → install → restart, or cd ComfyUI/custom_nodes && git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes then restart. No models, no heavy dependencies.

CategoryDerfuu_Nodes/Functions

Inputs (5)

NameTypeDefaultDescription
OperationCOMBO6 options: A > B, A < B, A = B, A AND B, A OR B, A XOR B
CompareValue_A*
CompareValue_Bopt*
OnTrueopt*
OnFalseopt*

Outputs (1)

NameTypeDescription
**