n8n-code-javascript

Write reliable JavaScript in n8n Code nodes with safe data access and return structures.

6.0k|1.0k|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/czlonkowski/n8n-skills --skill n8n-code-javascript-czlonkowski
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/czlonkowski/n8n-skills/tree/main/skills/n8n-code-javascript
Command: npx skills add https://github.com/czlonkowski/n8n-skills --skill n8n-code-javascript-czlonkowski

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured approach to writing reliable JavaScript in n8n Code nodes, eliminating ambiguity around data access, return formats, and webhook data handling.

Core Features & Use Cases

  • Access and transform input with $input.all(), $input.first(), and $input.item in Run Once for All Items or Run Once for Each Item modes.
  • Use built-in helpers like $helpers.httpRequest, DateTime (Luxon), and $jmespath for API calls, date calculations, and JSON querying.
  • Enforce correct return structure: an array of objects each containing a json property; handle webhook payloads under .body safely.
  • Real-world use: aggregate data across items, perform batch calculations, and prepare data for downstream nodes.

Quick Start

Start by creating a Code node, switch to Run Once for All Items, access data with const items = $input.all(), process with map(), and finish by returning an array like [{json: {...}}].

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 an n8n Code node to process multiple items?

To write JavaScript for multiple items in an n8n Code node, use Run Once for All Items mode, access input data with $input.all(), process the array with map(), and return an array of objects containing a json property like [{json: {...}}].

What is the correct return format for JavaScript code in n8n Code nodes?

The correct return format for n8n Code nodes is an array of objects, where each object contains a json property. Returning malformed structures without the json key prevents downstream nodes from accessing the processed data correctly.

Why does my n8n Code node fail when I use expression syntax in JavaScript?

An n8n Code node fails with expression syntax because it expects pure JavaScript, not n8n expressions. You must write standard JavaScript code to access data, using built-in helpers like $helpers.httpRequest instead of inline expressions.

Can I use built-in helpers like Luxon DateTime and JMESPath in n8n Code nodes?

Yes, you can use built-in helpers in n8n Code nodes to perform date calculations with DateTime (Luxon), query JSON with $jmespath, and make API calls using $helpers.httpRequest directly within your JavaScript transformations.

How do I access webhook payload data safely inside an n8n Code node?

To access webhook payload data safely in an n8n Code node, reference the incoming item's json property and extract the payload under the .body object, ensuring secure data handling before performing transformations or API calls.

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

Use Run Once for Each Item in n8n when processing individual items sequentially with $input.item, and use Run Once for All Items when aggregating data or performing batch calculations across multiple items with $input.all().