Code Node Sandbox Reference
What you can and cannot do in Code Nodes — constraints, available variables, and performance tips.
Written By pvdyck
Last updated About 3 hours ago
Code Node Sandbox Reference
Code Nodes run in a secure, isolated sandbox. This page explains what is available and what constraints apply.
Constraint Table
CPU Time Limit
Each Code Node execution has a 2-minute CPU time limit. This counts actual CPU computation, not wall-clock time. Infinite loops will be terminated.
Performance Tips
The sandbox engine is optimized for lightweight logic. Complex string manipulation or large array operations may be noticeably slower than in a browser. Keep Code Node logic lean — offload complex processing to upstream HTTP Request nodes where possible.
Available n8n Variables
$input— input items (.all(),.first(),.last(),.item(),.context,.params)$json— shortcut to first item's JSON$('NodeName')— access other nodes (.first(),.last(),.all(),.item(),.json,.context,.params)$node['Name']— proxy-based node accessor (.json,.binary,.context,.parameter,.runIndex)$item(n)— access item by index$items()— all items asINodeExecutionData[]$prevNode— previous node info (name,outputIndex,runIndex)$workflow— workflow metadata (id,name,active)$env— environment variables$vars— workflow variables$execution— execution metadata$mode— execution mode$now,$today,$yesterday— Luxon-like dates (.toISO(),.toFormat(),.plus(),.minus())DateTime— date factory (.now(),.fromISO(),.fromJSDate())$nodeVersion,$nodeId— node metadata$itemIndex,$runIndex— current indices$getNodeParameter— access node parameters