Stage 2 · Lesson 5 of 8
The Code node
The runs your own , or Python, when built-in nodes and are not enough. Typical jobs are reshaping nested data, custom validation or grouping records. It has two modes.
In Run Once for All , $input.all() gives you every item at once. In , your code runs separately for each one. Whatever you return must be a list of items, each shaped as { json: {...} }.
On n8n Cloud you cannot import external npm packages (ready-made code libraries); self-hosted instances can allow them. Keep Code nodes short and clearly named, because the next person to maintain the workflow may not read code.
Common trapreturning plain objects instead of items, or writing a 200-line script that should be three simple nodes.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with
- CourseFreen8n Academy
n8n · Beginner
Free official courses from Essentials to APIs and AI, each with a certificate and badge