n8n-code-javascript

Write and run JavaScript in n8n Code nodes for data processing.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/erlebach/gordon --skill n8n-code-javascript-erlebach
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/erlebach/gordon/tree/main/skills/agent_skills/n8n-code-javascript
Command: npx skills add https://github.com/erlebach/gordon --skill n8n-code-javascript-erlebach

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Code nodes in n8n require correct data access, robust return formats, and safe handling of inputs to unlock complex automation. This guide provides practical patterns for writing JavaScript in Code nodes, how to navigate $input/$json/$node syntax, and how to leverage built‑ins like $helpers.httpRequest and DateTime.

Core Features & Use Cases

  • Data access patterns: $input.all(), $input.first(), and $input.item enable batch processing, single-object API responses, and per-item logic.
  • Return format discipline: always produce an array of objects with a json property, enabling downstream nodes to consume results reliably.
  • Built-in utilities: access HTTP via $helpers.httpRequest, perform date/time operations with DateTime (Luxon), query JSON with $jmespath, and perform persistent storage with $getWorkflowStaticData().
  • Gotchas and best practices: correct webhook data structure under .body, avoid using {{ }} expressions in code, and implement null checks and error handling.
  • Mode guidance: Run Once for All Items as the default mode; Run Once for Each Item for per-item workflows, with examples.

Quick Start

Create a Code node, use Run Once for All Items, read all inputs with $input.all(), transform them, and return an array of {json} objects.

Frequently Asked Questions about n8n-code-javascript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write JavaScript in n8n Code nodes to process workflow data?

To write JavaScript in n8n Code nodes, use $input.all() to read all input items, transform the data, and return an array of objects with a json property to ensure downstream nodes can consume the results reliably.

What is the correct return format for n8n Code nodes?

The correct return format for n8n Code nodes is an array of objects containing a json property, such as [{json: {...}}]. Enforcing this return format discipline ensures downstream nodes can consume results without errors.

How do I access webhook data in an n8n Code node?

To access webhook data in an n8n Code node, target the data structure under the .body property. Apply null checks and error handling to safely manage incoming webhook payloads during workflow automation.

When should I use Run Once for All Items vs Run Once for Each Item in n8n?

Use Run Once for All Items as the default mode for batch processing with $input.all(), and switch to Run Once for Each Item when you need per-item logic executed individually across your n8n workflow data.

Can I use Luxon and HTTP requests inside n8n Code nodes?

Yes, you can use DateTime (Luxon) for date/time operations and $helpers.httpRequest to make HTTP calls inside n8n Code nodes, alongside built-in utilities like $jmespath for querying JSON data.

Why does using expressions in n8n Code nodes cause errors?

Using {{ }} expressions inside n8n Code nodes causes errors because the JavaScript execution environment does not parse expression syntax. You must write pure JavaScript to handle data access and transformation safely.