Compare Numbers to Combo
Turn a number check into a text choice
- *
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
aandb- the two integers. Note these are INT, not FLOAT. If your source is a float (like astrengthorscale), you'll need to round or convert it first, or the wire won't connect.comparison- the six-operation dropdown. Defaults toa == 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT | First number to compare (left side of comparison). | |
| b | INT | Second number to compare (right side of comparison). | |
| comparison | COMBO | a == b | Comparison operation to perform between numbers a and b (==, !=, <, >, <=, >=). |
| string_true | STRING | Value to return when the comparison is true. Can be any string or value. | |
| string_false | STRING | Value to return when the comparison is false. Can be any string or value. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |