Eval
Run Real Python in Your ComfyUI Graph — No Training Wheels, No Sandbox
- input1
- *
ComfyUI is a graph of fixed nodes, and every once in a while you need to compute something the graph has no node for - multiply two dimensions, format a string, filter a list - without writing a whole custom node. The Eval node from ComfyUI-Small-Utility is the bluntest answer to that: a box where you type Python, run the queue, and the result comes out the other side. It's the same family as rgthree's Power Puter (an allowlisted expression evaluator) and Impact Pack's execute-any-code, except this one is raw exec() with nothing between you and the interpreter.
How it works
The node takes your cmd text and hands it straight to Python's exec():
exec(cmd, {}, kwargs)
Everything you feed into the node's inputs becomes a variable in that scope. input1 is available by name in your code. result starts out as None, and whatever you assign to result is what the node outputs:
result = input1 * 2 # double a number
result = "batch is " + str(input1) # build a string
That's the whole contract. The frontend extension handles the plumbing: plug a wire into the input and it auto-creates input2, input3, and so on, renaming each one as you go. There's also a result_type widget that renames and retypes the single output, which helps downstream nodes accept it.
Inputs and outputs
Only two things matter:
- cmd - multiline text, the Python you want to run. This is required.
- input1 - an optional input of any type (
*), exposed as a variable insidecmd.
One output, typed * by default, which in ComfyUI terms means "connects to anything." You set its real type with the result_type widget.
The part nobody warns you about enough
This is arbitrary code execution on your machine. exec() has no sandbox, no allowlist, no permission prompt: your cmd can import os, read and delete files, call torch, open sockets. That's not a bug, it's the entire point - but it means a shared workflow containing an Eval node is effectively an executable, and the custom-node ecosystem already runs on trust with no sandboxing to back it up. Don't paste a cmd you don't understand, and don't load random workflows with one of these in them. If all you need is arithmetic or string math, Power Puter's allowlist is the safer cousin.
Common issues
- You get
Noneout. You forgot to assignresult. It's preset toNoneprecisely so you see this mistake instead of a silent empty output. - A Python traceback on the node. Your code threw. ComfyUI surfaces the error, so at least it tells you the line.
- The node's output won't type-check. Leave
result_typeas*and it'll plug into almost anything; set it wrong and ComfyUI starts complaining.
Installing it
The pack is two Python files and a prebuilt frontend bundle - no requirements.txt, no model downloads, nothing to compile:
cd ComfyUI/custom_nodes
git clone https://github.com/changwook987/ComfyUI-Small-Utility
Restart ComfyUI. Because the node's brain is partly a browser extension, hard-refresh the UI too if the Eval node doesn't show its extra widgets. ComfyUI Manager users can just search "ComfyUI-Small-Utility" and install it there. The same pack also throws in two right-click menu extras - "SDXL Sizes" on EmptyLatentImage and "sort prompt" on any node - which are handy but unrelated to this node.
Verdict
Genuinely useful if you write code and want Python mid-pipeline; a footgun if you don't. I reach for it a couple of times a month to compute something the graph can't express, and I'm always a little relieved when I don't need it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| cmd | STRING | — | |
| input1opt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |