π§ Simple Math Condition
Simple Math Condition β a tiny if/else that returns numbers
- evaluate
- a
- b
- c
- INT
- FLOAT
This is the "if/else" of the Essentials math family. You give it a condition to evaluate and two expressions - one to compute if the condition is true, one if it's false - and it returns the resulting number. It's small, but it's the piece that lets a workflow decide a value instead of hard-coding it.
If you've ever wanted "if the image is portrait use these dimensions, otherwise use those," this is the node that expresses it.
What it does
Three required inputs and three optional ones:
- evaluate - the condition, typed as
*(wildcard). This is what gets tested for truthiness. Zero/false takes the false branch; anything else takes the true branch. - on_true - a string expression evaluated and returned when the condition is true.
- on_false - a string expression evaluated and returned when the condition is false.
- a, b, c (optional) - wildcard inputs you can reference inside those expressions. Wire numbers into a/b/c and use them in
on_true/on_falseto compute a result from your actual workflow values.
It outputs both an INT and a FLOAT of the result, so whichever type the downstream node wants, it's there - no convert node in between.
The mental model: it's a one-line ternary. evaluate ? on_true : on_false, where the two branches are little math expressions that can reference a, b, and c.
Why it's useful
Most conditional needs in a workflow aren't about branching the graph - they're about branching a number. Steps, dimensions, a strength, a count. Simple Math Condition lets you fold that decision into a single node rather than building a whole switch-node contraption. Feed it a comparison result (from Simple Comparison, which outputs a boolean this node can evaluate) and you've got a clean little decision unit: compare two things, then emit one number or another based on the outcome.
It also pairs naturally with the rest of the pack's logic nodes. Simple Comparison decides, Simple Math Condition acts on the decision, Simple Math Boolean supplies constant flags. Together they let you build genuinely adaptive graphs without leaving ComfyUI for a scripting node.
Installing it
Part of ComfyUI Essentials by cubiq - Matteo Spinelli, the developer behind the community-standard ComfyUI_IPAdapter_plus:
- ComfyUI Manager: search "ComfyUI Essentials" β Install β restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/cubiq/ComfyUI_essentials, installrequirements.txt, restart.
Look for the π§ wrench and the + (SimpleMathCondition+).
Gotchas
The expression fields are strings that get evaluated, so a typo in on_true / on_false - a stray operator, a variable name that isn't a/b/c - surfaces as an error at run time, not when you type it. Keep the expressions simple and test them by dropping a Display Any on the output to confirm the number is what you expect.
Be clear about what "truthy" means for evaluate: 0 is false, non-zero is true. If you're feeding a float that lands very near zero, make sure it's actually the value you think it is.
If you already run pysssss's Custom Scripts, its math node covers a lot of this ground too - no need to stack both if one does what you want. And the pack-level caveat: cubiq set Essentials to maintenance-only in April 2025. It still works, but if the node breaks after a major ComfyUI update, roll ComfyUI back or patch it yourself, and if it shows up red as "missing," reinstall through Manager after checking the startup log.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| evaluate | * | 0 | β |
| on_true | STRING | β | |
| on_false | STRING | β | |
| aopt | * | 0 | β |
| bopt | * | 0 | β |
| copt | * | 0 | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| INT | INT | β |
| FLOAT | FLOAT | β |