Code
Run custom JavaScript against upstream workflow data.
The Code node runs small JavaScript transformations in a sandbox and passes the returned value downstream. Use it when the Transform node's visual pipeline is not expressive enough for custom math, grouping, reducing arrays, or normalizing inconsistent nested data.
Code nodes are synchronous. They can read upstream data through $input and must return a JSON-serializable value.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
| JavaScript | string | Yes | Code to run. Use $input to read upstream node outputs and return the downstream value |
| Timeout (ms) | number | No | Execution deadline. Values are clamped between 100 and 10000 ms |
| Output Variable | string | No | Name used by downstream nodes. Defaults to codeResponse |
| Node Label | string | No | Display name shown on the canvas |
How it works
- Upstream node outputs are collected into
$input - Your JavaScript runs in a sandboxed QuickJS runtime
- The returned value is saved as this node's output
- Downstream nodes reference it through the configured output variable
The sandbox does not provide host APIs such as fetch, process, filesystem access, npm imports, or timers. Use integration nodes for network calls and the Code node for data shaping.
Working with $input
The node settings Input pane shows the upstream sample passed to $input. Click a value in the Input pane while the JavaScript editor is focused to insert the matching $input access at the cursor.
Examples:
$input.pumpfunResponse.data[0].symbol
$input["price-feed"].data.valueThe Input pane also includes JSON, Schema, and Table views when you need exact inspection instead of the default Variables browser.
Example: rank Pump.fun top tokens
Workflow:
Manual Trigger → Pump.fun getTopRunners → Code → TelegramSet the Pump.fun node output variable to pumpfunResponse. Then add this Code node:
const tokens = Array.isArray($input.pumpfunResponse?.data)
? $input.pumpfunResponse.data
: [];
const ranked = tokens
.filter((token) => {
return (
token.mint &&
token.name &&
token.symbol &&
token.priceSol != null &&
token.bondingProgressPct != null
);
})
.map((token) => ({
mint: token.mint,
name: token.name,
symbol: token.symbol,
priceSol: token.priceSol,
bondingProgressPct: token.bondingProgressPct,
score:
Number(token.bondingProgressPct) * 2 + Number(token.priceSol) * 100000,
}))
.sort((a, b) => b.score - a.score)
.slice(0, 5);
return {
count: ranked.length,
tokens: ranked,
};If the Code node output variable is rankedTokens, a downstream Telegram or Discord node can use:
Top Pump.fun runner: {rankedTokens.data.tokens[0].symbol}
Mint: {rankedTokens.data.tokens[0].mint}
Progress: {rankedTokens.data.tokens[0].bondingProgressPct}%Output
A successful Code node returns:
{
"success": true,
"data": {
"count": 5,
"tokens": []
}
}Downstream nodes reference the returned value under .data:
{codeResponse.data}
{codeResponse.data.tokens[0].symbol}If you set Output Variable to rankedTokens, use:
{rankedTokens.data.tokens[0].symbol}Previewing
Code settings use the shared node-settings layout:
- Input shows upstream sample data available as
$input. - Parameters contains the JavaScript editor, timeout, output variable, and node label.
- Output shows a Live preview for the current draft and a Last tab for the most recent persisted run output.
The Live preview runs your draft code in the same QuickJS sandbox used by workflow execution, using the current upstream sample. It is for inspection while editing; execute the node or workflow to persist a last-run output.
If the Code node has no input sample, use the Input pane button to execute previous nodes. This runs previous nodes and uses their latest outputs as preview data. Preview runs count as monthly runs and are hidden from normal execution history. If upstream nodes can send messages, transfer funds, trade, or broadcast transactions, the editor asks for confirmation before firing them.
Limits
| Limit | Value |
|---|---|
| Timeout | 100-10000 ms |
| Memory | 16 MB |
| Stack | 1 MB |
| Output size | 5 MB |
The returned value must be JSON-serializable. Returning functions, symbols, circular objects, or unsupported values causes the node to fail.
When to use Code vs Transform
Use Transform when your data change fits the visual pipeline:
- Filter, sort, and slice arrays
- Keep, drop, or rename fields
- Add fixed fields
- Add template-derived fields
- Compute age from timestamps
Use Code when you need arbitrary JavaScript logic:
- Custom scoring or math
- Grouping or reducing arrays
- Normalizing inconsistent API shapes
- Handling branching data structures that do not fit the visual steps
- Building a custom object for alerts or downstream trades
Next steps
- Transform - visual pipeline-based reshaping
- Configuring Nodes - input/output panes and variables
- Filter - conditionally pass or block data
- Pump.fun - discover and trade Pump.fun tokens
