Run JavaScript

action_run_js · action · Utility · Available · v1.0.0

Description

Execute custom JavaScript in the in-process isolated-vm sandbox (the battle-tested V8 isolation used by Cloudflare Workers): no filesystem, no network, no modules — the escape hatch for any business-logic transformation the specific nodes do not cover.

⚙️ Configuration parameters

Fields shown in the editor when configuring the node. Generated directly from the NodeDefconfigFields.

FieldTypeRequiredDefaultDescription
code
Codice JavaScript
codeyes// input = output del nodo precedente // vars = workflow variables // ctx = { tenantId, runId, nodeId } const items = input.items || []; const total = items.reduce((s, x) => s + (x.amount || 0), 0); return { total, count: items.length }; Codice JS. Usa "return <value>" per emettere output (JSON-serializable). Strict mode. No require/import/fetch/process/eval. Per data transformation pattern n8n-compat usa logic_transform (più ergonomico).
timeoutMs
Timeout (ms)
numberno5000Tempo massimo esecuzione. Min 100, max 30000. Default 5s.
memoryLimitMb
Memory limit (MB)
numberno128Limite memoria isolated-vm. Min 16, max 512. Default 128MB.

💡 Configuration example

JSON snippet of the node as it appears in the workflow. Values are derived fromdefaultValue and from required parameters.

{
  "id": "node-action_run_js-1",
  "defId": "action_run_js",
  "label": "Run JavaScript",
  "config": {
    "code": "// input = output del nodo precedente\n// vars = workflow variables\n// ctx = { tenantId, runId, nodeId }\n\nconst items = input.items || [];\nconst total = items.reduce((s, x) => s + (x.amount || 0), 0);\nreturn { total, count: items.length };\n",
    "timeoutMs": 5000,
    "memoryLimitMb": 128
  }
}

🔗 Related nodes in the same category

Ready to use Run JavaScript?

Available now on all FlowForge plans. Try it free without a credit card.

Start freeBrowse all nodes