← All tools
Run Node.js code
Codecode.run_node
in: anyout: text
Execute Node.js in a sandboxed runtime.
Pricing
- Price
- 6.25 cr / second
Prices in credits (1 credit = $0.01).
Run Node.js Code
Execute a Node.js snippet in an isolated sandbox and return the value of result.
When to use
- JSON manipulation — parse, transform, or validate JSON payloads with native JS tooling.
- String processing — use regex, template literals, or Buffer operations.
- Lightweight scripting — run any logic that benefits from the Node.js standard library.
Inputs & outputs
| Input modality | Any (named variable bindings via vars) |
| Output modality | Text / JSON (the value of result after execution) |
| Max source length | 50 000 characters |
| Max timeout | 30 seconds |
Parameters
| Param | Required | Description |
|---|---|---|
source | yes | Node.js source code (1–50 000 chars). Must assign to result. |
timeout_seconds | no | Execution time limit in seconds (1–30). Default: 5 |
Input
| Field | Description |
|---|---|
vars | Dictionary of named bindings injected as local variables before execution. Values can be any JSON-serialisable type. |
Examples
Simple arithmetic
{
"type": "code.run_node",
"input": { "vars": {} },
"params": { "source": "result = 1 + 1", "timeout_seconds": 5 }
}
Transform an array with input variables
{
"type": "code.run_node",
"input": { "vars": { "items": ["foo", "bar", "baz"] } },
"params": { "source": "result = items.map(s => s.toUpperCase()).join(', ')", "timeout_seconds": 5 }
}
Pricing
Billed per second of sandbox execution time (rounded up to the nearest second). See pricing dashboard for current rates.
Related capabilities
code.run_python— execute Python code in a sandboxweb.search— retrieve live data to process with this capability
Examples
Inline add
{
"source": "result = 1 + 1",
"timeout_seconds": 5
}