Code Node
When a Transform node stops being enough, this is the escape hatch: plain JavaScript over the payload, returning whatever the rest of the flow should see. It runs in a locked-down sandbox with a small, deliberate set of globals — no network, no filesystem, no imports.
The shape of the code
Your code is wrapped in a function, so return works at the top level and is how you produce the output.
// Write your JavaScript here
// `payload` is available as input
// Return an object to pass downstream
// Return null to block the event
return payload;- Return an object and it becomes the payload for everything downstream.
- Return
nulland the event stops here. That is the supported way to make the Code node act as a filter.
What exists inside the sandbox
This is the whole list. Anything not here is undefined — there is no require, no fetch, no setTimeout, and no Promise, so the code is synchronous by construction.
| Global | What it is |
|---|---|
| payload | The incoming payload, complete — not a trimmed projection. |
| $("name") | Any other node's last output in the same workspace, by node name. |
| headers | The incoming request headers, as a plain object. |
| meta | Event metadata for the current run. |
| console | log, warn, error — captured and shown in the Console section, not sent to a server log. |
| JSON | Only parse and stringify. |
| Object | Only keys, values, entries, assign, freeze. |
| Array | Only isArray, from, of. Instance methods (map, filter…) work normally. |
| Math · Date · RegExp | Complete. |
| String · Number · Boolean | Complete. |
| Map · Set | Complete. |
| parseInt · parseFloat · isNaN · isFinite | Complete. |
| encodeURIComponent · decodeURIComponent | Complete. |
[] instanceof Array is false in here. The sandbox is a separate realm: an array literal you create gets the sandbox's prototype while Array comes from outside it. Use Array.isArray(x), which is exposed precisely for this.Reaching another node
const cliente = $("Buscar cliente");
const pedido = payload;
if (!cliente || !cliente.email) return null; // nothing to send: stop here
return {
to: cliente.email,
asunto: `Pedido ${pedido.id} confirmado`,
total: pedido.items.reduce((s, i) => s + i.price * i.qty, 0),
};The argument is the node's name as it reads on the canvas, so renaming a node breaks the reference — the editor autocompletes the names to keep you honest.
Timeout
100 to 30,000 ms. It bounds your code, not the network — there is no network. A loop that does not finish inside the budget fails the node rather than the run.
The console, and Execute
The Execute button beside the editor runs the code on the spot and prints everything console.log produced into the Console section, followed by the returned value after a =>. Warnings and errors are colour coded. This is the fastest loop for getting a transform right; the Test Code runner below does the same against a full test payload.
Where the code actually runs
Not in the API process. Tenant code runs either in an isolated Cloudflare worker — the preferred path, because there is no private network there to reach — or, as a fallback, in a child process started with an empty environment and, where the runtime allows it, with the filesystem denied.
Date comes out the other side as an ISO string; a Map, a Set or a function does not survive. Convert before returning.Code node or Transform node?
Reach for Transform for renaming, reshaping, and templating — it is declarative and readable in the panel at a glance. Reach for the Code node when you need real logic: conditionals over several fields, aggregation, parsing a format nobody anticipated. If the code is three lines of property copying, Transform will age better.