ComfyUI Node

IF Int Condition

An if/else for integers that outputs one of two numbers

By DesertPixelAi·Created 2 years ago·Updated about a year ago· 25
IF Int Condition
    • INT
    if_value0
    if_logic
    compare_if_with0
    or_value0
    compare_or_with
    compare_or_value0
    result_if_true1
    result_if_false0

    This is an if/else statement wearing a node costume. You give it a comparison - is this number equal to / smaller than / bigger than that one - and it outputs one integer if the comparison is true and a different integer if it's false. That's it: a ternary for your graph. The output int then drives whatever you point it at, most often a switch that flips part of the workflow on the result.

    Why you'd want conditional logic in a node graph at all: ComfyUI has no native "if this, do that." Workflows run every node every time. So when you want behavior to change based on a value - take a different branch when a counter passes a threshold, pick output A below some number and output B above it - you need a node that evaluates a condition and emits a value you can act on. This is that node, for integers.

    The inputs that matter

    The core comparison is three fields:

    • if_value - the number you're testing.
    • if_logic - equal, smaller, or bigger.
    • compare_if_with - the number you're testing against.

    So "if_value bigger than compare_if_with" is the question. Then two outcomes:

    • result_if_true (default 1) - the integer emitted when the comparison holds.
    • result_if_false (default 0) - the integer emitted when it doesn't.

    There's also an optional second clause - or_value, compare_or_with (off / equal / smaller / bigger), and compare_or_value - that lets you OR in a second condition. Set compare_or_with to off and it's ignored; set it to a comparison and the node returns true if either the first condition or this second one holds. Leave it off until you actually need two conditions.

    The single output is an INT - the chosen result.

    The realistic pattern

    Feed if_value from a counter or a DP int node, compare it against a threshold, and route the output into a switch's index. Now the workflow takes one branch below the threshold and another above it - a poor man's control flow. The default true/false of 1/0 is deliberately switch-friendly: 1 and 0 map cleanly onto a two-way toggle.

    How to install it

    ComfyUI Manager: search ComfyUI-Desert-Pixel-Nodes, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes
    

    then restart. No models, no dependencies. Under the "DP" / "Desert Pixel" Logic category.

    Common issues & troubleshooting

    It's not actually branching my workflow. This node outputs a number, not a flow-control signal - it doesn't stop downstream nodes from running. You have to feed its output into something that acts on the value, like a switch's index or another node's mode input. On its own it just computes an int.

    The OR clause is firing when I didn't expect it. Check compare_or_with. If it's set to anything other than off, the second condition is live and the node returns true when either clause is satisfied. Set it to off to test on the first condition alone.

    It only handles integers. Right - equal/smaller/bigger on whole numbers. If you need to branch on a float, a string, or a boolean, this isn't the node; round to an int first or use a comparison built for that type.

    CategoryDesert Pixel/Logic

    Inputs (8)

    NameTypeDefaultDescription
    if_valueINT0-18446744073709550000–18446744073709550000
    if_logicCOMBO3 options: equal, smaller, bigger
    compare_if_withINT0-18446744073709550000–18446744073709550000
    or_valueINT0-18446744073709550000–18446744073709550000
    compare_or_withCOMBO4 options: off, equal, smaller, bigger
    compare_or_valueINT0-18446744073709550000–18446744073709550000
    result_if_trueINT1-18446744073709550000–18446744073709550000
    result_if_falseINT0-18446744073709550000–18446744073709550000

    Outputs (1)

    NameTypeDescription
    INTINT