Code
Run your own JavaScript when a node isn't enough.
When the built-in nodes can't express the logic you need, the Code node lets you write custom JavaScript that runs server-side as part of the workflow. It receives the data from the previous node, can read values saved earlier in the run, and produces output for the next node.
When to use it
- Calculate or reformat a value that no other node covers.
- Apply conditional logic that's easier to write than to wire up visually.
- Read values your Store nodes saved earlier in the run.
Inputs & outputs
| Input handle | One — the data from the previous node. |
| Output handle | One — the result your code produces. |
What's available inside your code
| Variable | What it holds |
|---|---|
input | The data passed in from the previous node. |
store | The run's shared store. Values saved by Store nodes are read as store.<key>. |
The output your code produces becomes the input of the next node.
Example
Given this input from the previous node:
{ "firstName": "sam", "lastName": "lee", "total": "19.99" }
Your code can normalize and enrich it:
const fullName = `${input.firstName} ${input.lastName}`.trim();
const result = {
customerName: fullName.toUpperCase(), // "SAM LEE"
total: Number(input.total), // 19.99 as a number
region: store.region ?? "unknown", // read a value a Store node saved
};
return result;
The next node then receives:
{ "customerName": "SAM LEE", "total": 19.99, "region": "unknown" }
:::info Confirm before publishing
The available variables (input, store) are correct for your engine. Please confirm how the node reads your output — i.e. whether it's a return statement (as shown) or a value assigned to a specific variable — against your Js.php executor so this example matches exactly. Send me that file and I'll lock the example down.
:::
Keep Code nodes small and focused. For transforming data between systems, prefer a Mapping node — it's visual, testable, and reusable across workflows.