Nodes/ComfyUI-Przewodo-Utils/Compare Numbers to Combo
ComfyUI Node

Compare Numbers to Combo

Turn a number check into a text choice

By przewodo·Created about a year ago·Updated 4 months ago· 4
Compare Numbers to Combo
    • *
    a
    b
    comparisona == b
    string_true
    string_false

    ComfyUI workflows turn into little programs eventually, and the moment that happens you need an if/else. This node is the "if" part for numbers: you compare two integers, and depending on whether the comparison is true or false, the node hands you back one of two strings you typed in.

    The classic use case is dynamic prompt selection. Say you've got a seed, a frame count, or a step counter feeding in, and you want the workflow to pick a different style prompt based on that value - frames > 60 gets the "detailed motion" prompt, otherwise the "stable shot" prompt. Wire the number in, set the comparison and the two strings, and the output feeds straight into a CLIP Text Encode. No manual flipping between runs.

    How it works

    Under the hood it's the simplest possible mapping. There's a small table of six comparison functions (==, !=, <, >, <=, >=) and the node evaluates the one you picked from the comparison dropdown against a and b:

    • If the comparison is true, the output is string_true.
    • If it's false, the output is string_false.

    The output is typed * (the wildcard), so the "combo" in the name means you get a text value you can also push into anything that accepts a string - a filename suffix, a LoraStack name, a note. It's a dead-simple pattern, but it's the atom you build conditional workflows from, and it saves you from burying the same logic in five different places.

    The inputs that matter

    • a and b - the two integers. Note these are INT, not FLOAT. If your source is a float (like a strength or scale), you'll need to round or convert it first, or the wire won't connect.
    • comparison - the six-operation dropdown. Defaults to a == b.
    • string_true / string_false - what comes out on each branch. Can be any text (or a number typed as text).

    One output, wildcard-typed, carrying whichever string won.

    Installing it

    Part of the ComfyUI-Przewodo-Utils pack. ComfyUI Manager → search ComfyUI-Przewodo-Utils, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/przewodo/ComfyUI-Przewodo-Utils.git
    

    Restart, and it shows up under PrzewodoUtils. The pack pulls heavier deps for its Wan sampler, but this node needs none of them - it only uses Python's built-in comparisons.

    Where people get tripped up

    The INT-only limitation is the one that bites. This pack also ships a FloatIfElse, which is the float counterpart - if your condition involves a decimal, grab that node instead of fighting the type system. And remember the output is a string: if you need the result to be a real number downstream (like a switch feeding a sampler), you'll want a different routing node. For choosing between two pieces of text based on a number, though, this is about as frictionless as it gets.

    CategoryPrzewodoUtils

    Inputs (5)

    NameTypeDefaultDescription
    aINTFirst number to compare (left side of comparison).
    bINTSecond number to compare (right side of comparison).
    comparisonCOMBOa == bComparison operation to perform between numbers a and b (==, !=, <, >, <=, >=).
    string_trueSTRINGValue to return when the comparison is true. Can be any string or value.
    string_falseSTRINGValue to return when the comparison is false. Can be any string or value.

    Outputs (1)

    NameTypeDescription
    **