n8n-code-javascript

Write robust JavaScript for n8n Code nodes to transform and validate workflow data.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/HustleDanie/n8n-claude-kit --skill n8n-code-javascript-hustledanie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/HustleDanie/n8n-claude-kit/tree/main/skills/n8n-code-javascript
Command: npx skills add https://github.com/HustleDanie/n8n-claude-kit --skill n8n-code-javascript-hustledanie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It eliminates common failures when writing JavaScript in n8n Code nodes—especially wrong return format, confusing $input mode usage, and incorrect webhook field access that causes workflows to break.

Core Features & Use Cases

  • Mode selection clarity (All Items vs Each Item): Guides you to pick the right execution mode and access data correctly with $input.all(), $input.first(), and $input.item.
  • Correct return format enforcement: Ensures your Code node returns data in the required array-of-items structure using the {json: {...}} wrapper.
  • Built-in helper and function mastery: Covers $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and safe access patterns for working with APIs, dates, and JSON.
  • Production patterns & error prevention: Provides battle-tested transformation patterns and explains top Code node error scenarios with fixes, including null-checks and expression syntax confusion.
  • Webhook data gotcha explained: Fixes the most frequent mistake by clarifying that webhook payloads live under $json.body (or $input.first().json.body).

Quick Start

Ask: "Show me the correct n8n Code node JavaScript to transform webhook POST data under $json.body into an output array of items, and point out any common pitfalls."

Frequently Asked Questions about n8n-code-javascript

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

FAQPage Schema
How do I format the return value in an n8n Code node?

The n8n Code node return format must be an array of items wrapped in a {json: {...}} structure. Using the correct wrapper ensures your workflow data passes downstream without breaking the execution chain.

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

Webhook data in an n8n Code node is accessed under $json.body or $input.first().json.body. The payload lives nested inside the body property rather than at the root of the incoming item.

What is the difference between All Items and Each Item mode in n8n Code?

All Items mode processes the entire dataset at once using $input.all(), while Each Item mode iterates individually using $input.item. Choosing the wrong execution mode causes data access errors.

Why does my n8n Code node throw an error when transforming workflow data?

n8n Code node errors typically stem from a missing return statement, expression syntax confusion, or null/undefined values. Adding guard clauses before data access prevents these common workflow failures.

Can I use $helpers.httpRequest to call APIs inside an n8n Code node?

Yes, $helpers.httpRequest allows you to make HTTP requests directly within an n8n Code node. This helper integrates API calls alongside your JavaScript data transformation logic.

How do I handle DateTime and JSON queries in n8n JavaScript?

n8n Code nodes support Luxon DateTime for date manipulation and $jmespath for JSON queries. Using these built-in functions allows safe date formatting and structured data extraction.