Code node
A node that runs your own JavaScript to reshape data, filter items or call a library.
Last updated
Analogy
The escape hatch, like a custom middleware when no package does quite what you need.
In an agent
Handy for cleaning an agent's output before it reaches Slack or a database.
Questions people ask
What is the n8n Code node for?
The Code node runs your own JavaScript inside a workflow. Use it to reshape data, filter items, compute values or call a small library when no built-in node does quite what you need. It is the escape hatch, like custom middleware when no package fits.
Should agent logic go in an n8n Code node?
Keep it small there. A Code node is great for cleaning an agent's output before it reaches Slack or a database. Real agent logic, with its loops, tools and tests, belongs in normal code behind an API, where you can version it, test it and debug it properly.