n8n-code-javascript

Automate JavaScript coding in n8n Code nodes with correct return formats.

Updated Jan 16, 2026
One-click install
npx skills add https://github.com/Alkan-ia/Alkan-ia.github.io --skill n8n-code-javascript-alkan-ia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/Alkan-ia/Alkan-ia.github.io/tree/main/n8n-skills/skills/n8n-code-javascript
Command: npx skills add https://github.com/Alkan-ia/Alkan-ia.github.io --skill n8n-code-javascript-alkan-ia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides clear, actionable guidance for writing and debugging JavaScript inside n8n Code nodes, covering data access patterns, return formats, and safe webhook handling to build robust workflows.

Core Features & Use Cases

  • Data access mastery: Use $input.all(), $input.first(), and $input.item to read, transform, and aggregate data across batch and per-item processing.
  • Mode guidance: Understand Run Once for All Items vs Run Once for Each Item and apply the right approach for your workflow.
  • Reliability patterns: Enforce correct return structures, null checks, and safe access to webhook payloads (webhook data is under .body).
  • Built-ins & integration: Leverage $helpers.httpRequest, DateTime/Luxon, $jmespath, and other built-ins for API calls, date/time handling, and data shaping.
  • Error prevention: Follow production-ready patterns to avoid common mistakes and ensure consistent results.

Quick Start

  1. Create a Code node in your n8n workflow and set it to Run Once for All Items.
  2. Read input data with $input.all(), transform it, and return an array of objects with a json property, e.g. [{json: {…}}].
  3. When calling external services, use $helpers.httpRequest and handle responses; use DateTime from Luxon for date/time formatting.

Frequently Asked Questions about n8n-code-javascript

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

FAQPage Schema
How do I return data from an n8n Code node without getting an error?

To return data from an n8n Code node correctly, you must structure your output as an array of objects containing a json property, such as [{json: {…}}]. Using this exact format prevents workflow execution errors and ensures downstream nodes receive valid items.

Why is my webhook payload undefined in the n8n Code node?

Your webhook payload is undefined in the n8n Code node because webhook data is safely nested under the .body property. You must access it via the body object rather than expecting it at the root level of the incoming item to extract your request data successfully.

What is the difference between Run Once for All Items and Run Once for Each Item in n8n?

Run Once for All Items processes the entire input array in a single execution using $input.all(), while Run Once for Each Item iterates through each item individually using $input.item. Choosing the right mode depends on whether you need batch aggregation or per-item transformation.

Can I use expressions like {{ $json.field }} inside an n8n Code node?

You cannot use {{ }} expressions inside an n8n Code node because it executes pure JavaScript. You must access data directly using JavaScript syntax like $input.item.json.field and apply safe null checks to prevent runtime errors during workflow execution.

How do I make HTTP requests and format dates in an n8n Code node?

To make HTTP requests and format dates in an n8n Code node, use the built-in $helpers.httpRequest method for API calls and the DateTime object from Luxon for date manipulation. These built-ins allow you to fetch external data and format timestamps within your JavaScript code.

Does n8n Code node support Luxon for date and time manipulation?

The n8n Code node supports Luxon for date and time manipulation by exposing the DateTime object natively. You can utilize Luxon methods directly in your JavaScript code to parse, format, and calculate dates without importing external libraries.