Run Code
Run a sandboxed JavaScript snippet over wired JSON inputs.
Run Code
Node type: exec:code
Category: Data
Description
Runs a JavaScript snippet in a locked-down sandbox over your wired inputs. The script runs as an async function body: every resolved input port is available on a frozen inputs object keyed by port id, and the script must return a JSON-serializable value. Scoring formulas, dedupe checks, contract gates, and alignment logic belong here instead of one-off catalog nodes.
The sandbox has no network, no filesystem, and no access to secrets. Available globals: inputs, console.log (captured and returned as logs), and the standard JavaScript intrinsics (JSON, Math, Date, Array, ...). require, process, and fetch do not exist.
Currently in a limited admin-only beta.
Canvas ports
These appear as port handles on the left side of the node.
| ID | Label | Details |
|---|---|---|
input_1 |
Input 1 | JSON |
input_2 |
Input 2 | JSON |
Add as many JSON input ports as you need; each becomes a key on inputs.
Sidebar config
These render as form fields in the right-side config panel when the node is selected.
| ID | Label | Details |
|---|---|---|
code |
Code | TEXT (required) · multiline. The script (plain JavaScript) |
timeoutMs |
Timeout (ms) | NUMBER · default 10000, max 60000 |
Outputs
| ID | Label | Type |
|---|---|---|
output |
Output | JSON |
logs |
Logs | TEXT |
Limits and failure semantics
- Returned value must be JSON-serializable and at most 1 MB serialized. Exceeding the cap is a failure, not a truncation.
- Captured logs cap at 64 KB.
- A thrown error fails the node with the error message.
- Returning
{ __fail: true, error, failures: [{ id?, rule?, message }] }fails the node while preserving the structuredfailureslist (the hook for future automated retry loops).
Worked example: score and pick the best item
Wire an LLM or import node emitting a JSON array into input_1, then:
// inputs.input_1 = [{ id, views, ageHours }, ...]
const scored = inputs.input_1.map((it) => ({
...it,
score: it.views / Math.max(it.ageHours, 1),
}));
scored.sort((a, b) => b.score - a.score);
console.log('best of', scored.length, 'is', scored[0].id);
return scored[0];
The winning item is available downstream on the output port; the log line arrives on logs.
Auto-generated from the Wireflow node registry.