Exec
Run arbitrary Python inline — and why that's exactly as risky as it sounds
- *
Sometimes you need a one-off transform - uppercase a string, do arithmetic on two numbers, reshape a list a particular way - and writing a whole custom node for it is overkill. Exec is the pack's answer: a text box where you write Python, your inputs show up as x[0], x[1], x[2] and so on, and whatever you assign to result becomes the node's output. It's a code cell dropped straight into your graph.
How it works
Wire in however many values you need - dynamic inputs, same pattern as Create List and Pack elsewhere in this pack, so connecting the last empty socket adds another. Inside the FUNC text box, those connected values are available in order as x[0], x[1], x[2], and the default starting point is literally result = x[0] - pass the first input straight through, which is a fine template to build from. Whatever you assign to result by the time execution finishes is what comes out the single * output socket.
The README is blunt about this one, and it's worth repeating rather than softening: "Exec runs arbitrary Python code. Use it only in workflows you trust." That's not boilerplate legal caution - it's a literal description of what the node does. There's no sandbox, no restricted execution environment, no allowlist of safe operations. Code in FUNC runs with the same permissions as ComfyUI itself, which on most setups means full filesystem access and network access. This isn't a quirk unique to this pack, either - it's the same story as every custom node in ComfyUI: they're plain Python, imported and executed with zero isolation, which is exactly the mechanism behind the ComfyUI_LLMVISION incident from 2024, where a malicious node distributed through normal channels compromised users' machines (including, notably, a Disney employee's) before the author was federally prosecuted. A node whose entire purpose is "run whatever code is in this text box" is that same risk surface, deliberately, on purpose, as a feature.
The inputs and outputs that matter
FUNC- the Python source, multiline, defaultresult = x[0]. Reference your connected inputs asx[0],x[1], etc., and assign the value you want returned toresult.
Dynamic value inputs beyond that (added by connecting the last empty socket), and one output typed *, carrying whatever result ended up as.
How to install it
ComfyUI Manager: search "ComfyUI-List-Utils," install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git
Restart afterward. No extra dependencies for the pack itself - but see below, since the code you write inside this node can obviously pull in whatever it wants.
Common issues & troubleshooting
You downloaded a workflow that contains an Exec node with code already in it. Read the FUNC box before you run it, every time, the same way you'd read a shell script before running it as root. This applies doubly to any workflow you didn't build yourself - a malicious FUNC body is functionally the same threat as a malicious custom node, just hidden inside a workflow file instead of a repo, which makes it easier to smuggle past a casual glance at "just a workflow JSON."
result is never assigned, and the node errors on run. The code needs to explicitly set result - there's no implicit return. If your logic has branches, make sure every path assigns it, or initialize result at the top before your conditional logic.
Import errors for a library you tried to use. Exec runs inside ComfyUI's existing Python environment, so it only has access to whatever's already installed there. It's not a fresh interpreter with its own package set - if a library isn't already part of your ComfyUI install, importing it inside FUNC will fail the same way it would in a plain Python script.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| FUNC | STRING | result = x[0] | Python code to execute. Input values are x[0], x[1], ... Assign the value to return to result. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | The value assigned to result inside FUNC. |