Code Execution Nodes Reference

Guide to Code Node, Function Node, and QuickJS executor for custom JavaScript logic.

Written By pvdyck

Last updated About 5 hours ago

Code Execution Nodes Reference

Execute custom JavaScript code to transform data, implement custom logic, or integrate with services.

Code Node / Function Node

ID: 3124377

Write custom JavaScript to process workflow data. Access input via $input.all() and return output.

Features:

  • Full JavaScript syntax
  • Access to workflow data
  • Custom logic and transformations
  • n8n date helpers: $now, $today, $yesterday, DateTime
  • Cross-node access: $('NodeName'), $node['Name']

QuickJS Limitations:

  • No async/await (no network calls)
  • No console.log (use for debugging in editor only)
  • No file system access
  • No NPM modules
  • 2-minute CPU time limit per execution (CPU computation only; network wait time does not count)

Use For: Data transformation, custom business logic, string manipulation, calculations.


QuickJS Executor Reference

ID: 5983491

Underlying JavaScript engine (QuickJS in WebAssembly) that executes Code/Function nodes.

Security: Runs in a strict sandbox. No network, no file access, limited memory.

Best Practices:

  • Keep code simple and fast
  • Test in editor before deploying
  • Use built-in JavaScript methods
  • Avoid loops over large datasets

Common Patterns

Transform Data

// Extract fields from inputconst items = $input.all();return items.map(item => ({  json: {    id: item.json.id,    name: item.json.name.toUpperCase(),    processed: true  }}));

Filter Items

// Only pass items with amount > 100const items = $input.all();return items.filter(item => item.json.amount > 100);

Add Computed Field

// Add total = price * quantityconst items = $input.all();return items.map(item => ({  json: {    ...item.json,    total: item.json.price * item.json.quantity  }}));

Related