Math Expression
A calculator that lives inside your graph — type the formula, get three outputs
- values
- FLOAT
- INT
- BOOL
ComfyUI has plenty of nodes that multiply two numbers or clamp a value. What it historically didn't have is a plain "type an expression, get an answer" node in core - the thing you reach for when you want a * b / 2 or max(a, b) * 0.8 without chaining five single-operation nodes together. Math Expression is that node. You write the formula, wire in your numbers, and it hands you the result as a float, an integer, and a boolean.
It ships with ComfyUI core, no install, and it's new in 2026. It's the upstream answer to the "Power Puter"-style expression nodes that custom packs have been selling for years.
How it works
The expression is evaluated with simpleeval, a sandboxed evaluator - no arbitrary Python, no __import__ tricks. That's the part worth trusting: this isn't an eval() footgun wearing a cute face. The numeric inputs are autogrow sockets named with lowercase letters - a, b, c, and so on up the alphabet - and you reference them by name in the expression. There's also a values list available in case you want to treat the inputs as a group, plus a small function library: min, max, abs, round, sqrt, ceil, floor, log, log2, log10, sin, cos, tan, int, float, pow, and sum.
The standard operators work too: + - * / % ** and comparisons. Comparison expressions are where the BOOL output earns its keep - a > b produces a genuine true/false you can feed into a logic node.
Inputs and outputs
Two inputs: expression, a multiline text box (default a + b), and values, the autogrow set of numeric inputs. Add sockets as you need them, each gets the next letter.
Three outputs from one calculation:
- FLOAT - the result as a float.
- INT - the same result truncated to an integer.
- BOOL - the truthiness of the result (comparisons give you real booleans; a plain number gives you true unless it's zero).
Where people get burned
The classic failure is empty input or a non-numeric result. simpleeval is strict: a formula that evaluates to a string, or produces inf or nan, raises an error instead of silently passing garbage along. If you hit that, check you're not accidentally mixing a string into a numeric socket.
Second: the variable names are fixed to lowercase letters. A + b fails; a + b works. It's a small thing, but it's the most common typo in the whole node.
Third: pow() has an exponent cap to stop you from computing 10^4000 and locking up your machine. Legit formulas never touch it; don't fight it. And remember the INT output truncates - it doesn't round. a / 3 where a is 10 gives you FLOAT 3.333 and INT 3. If you need rounding, wrap it: round(a / 3).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| expression | STRING | a + b | — |
| values | COMFY_AUTOGROW_V3 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | — |
| INT | INT | — |
| BOOL | BOOLEAN | — |