Purpose
The Code node runs your own Python code as a step in a workflow. Use it for data transformation, custom logic, calculations, reshaping data between nodes, or anything that’s easier to express in code than with other nodes. Like every other node, the Code node receives inputs from upstream nodes through the workflow’s variable store and returns output that downstream nodes can use. It’s the escape hatch for the moments when a quick bit of Python is clearer than wiring together a chain of nodes.Python is the only supported language today.
When to use Code vs other nodes
Reach for the right node for the job. The Code node is for logic you write yourself — not for talking to the outside world.| Node | Use it for |
|---|---|
| Code | Custom logic, calculations, and data transforms you express in Python |
| Tool | Acting on external systems via MCP (email, calendar, databases, files) |
| Agent | LLM reasoning, interpretation, and decisions over natural language |
| API | Direct HTTP calls to external services |
How it works
Inputs arrive from upstream nodes
The Code node reads its inputs from the variable store, exactly like other nodes. Data produced by previous nodes — and any files passed in as inputs — are available to your code.
Your Python runs in an isolated sandbox
Your code executes inside a strict, single-use sandbox with a working directory of its own. Each run is fully isolated and cannot see other executions or the platform itself.
Output is captured
The value your code returns becomes the node’s output. Console output is captured for debugging, and any files your code writes are registered as downloadable workflow files.
Writing code
Inside the node you write plain Python. You receive the upstream inputs and return a result that downstream nodes can use. A short example of the kind of code you’d write:There’s a size cap on the code you submit (around 50,000 characters), and captured console output is truncated if it gets very large (around 30,000 characters). Keep code focused and avoid printing huge payloads.
The sandbox
Code nodes run in a strict sandbox so that custom code stays safe and contained.No network access
Code can’t make outbound network calls. Use a Tool or API node to reach external services, then pass the results in.
Least privilege
Code runs as a non-root user with CPU, memory, and process limits.
Full isolation
Each run gets its own throwaway environment. Code can’t see other executions or the platform itself.
Wall-clock timeout
A time limit stops runaway code so a single step can’t run forever.
Working with files
The Code node gets a working directory you can read from and write to.- Input files — Files passed in as inputs are available for your code to read. Input files are limited to the current project.
- Output files — Any files your code writes out are captured and registered as downloadable workflow files. This means a Code node can produce a CSV, report, or image that later nodes — or you — can download.
summary.csv your code writes is captured as a downloadable workflow file.
Operator note: Operators can run the sandbox on Docker (typical for self-hosted and development) or Kubernetes (typical for production). This is transparent to workflow builders — the experience and limits are the same either way.
Best practices
Keep external calls out of Code nodes
Keep external calls out of Code nodes
The sandbox has no network. Fetch data with a Tool or API node first, then transform it in the Code node.
Return structured output
Return structured output
Return a dictionary with clearly named fields so downstream nodes can reference exactly what they need from the variable store.
Watch your output size
Watch your output size
Console output is truncated when very large. Print only what you need for debugging, and pass real results through the return value.
Use files for large artifacts
Use files for large artifacts
For reports, exports, or images, write a file rather than returning a giant string. Output files become downloadable workflow files.
Stay within the time limit
Stay within the time limit
A wall-clock timeout stops runaway code. Keep loops bounded and avoid heavy work that won’t finish in time.
Next steps
Workflow overview
See how nodes connect and how data flows through a workflow
Tool node
Reach external systems via MCP, then pass results into Code
Agent node
Add LLM reasoning when a step needs interpretation or decisions
Memory system
Understand the variable store that feeds your Code node