n8n-code-javascript

Write n8n Code node JavaScript with correct data access and return formatting.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing JavaScript inside n8n Code nodes often leads to subtle mistakes around input data access, execution mode handling, and return formatting, which can break workflows or cause inconsistent results.

Core Features & Use Cases

  • All Items vs All Items mode guidance for predictable execution and transformations.
  • Safe data access patterns using $input.all(), $input.first(), and $input.item, with explicit handling for webhook payloads under .body.
  • Robust error prevention and validation patterns drawn from the skill's reference guides, plus built-in utilities like DateTime and $helpers.httpRequest.
  • Use cases include data transformation, API integrations, complex logic, and multi-step workflows in production environments.

Quick Start

Set up a Run Once for All Items Code node that reads all inputs via $input.all(), transforms each item, and returns a properly wrapped [{json: {...}}] array.

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 using JavaScript?

To return data from an n8n Code node, you must wrap your output in a properly formatted array structure like [{json: {...}}] to ensure the workflow processes the transformed items correctly.

Why does my n8n webhook data access fail inside the Code node?

n8n webhook data access fails when you do not explicitly extract the payload from the .body property, which is required for safe data handling and reliable API integrations within your automated workflows.

How do I handle All Items vs Each Item execution modes in n8n?

Handling All Items vs Each Item execution modes in n8n requires using specific data access patterns like $input.all() for all items or $input.item for each item to achieve predictable transformations.

Can I use expressions inside an n8n JavaScript Code node?

You cannot use {{}} expressions inside n8n JavaScript Code nodes; you must implement data transformations and logic using pure JavaScript and built-in utilities like $helpers.httpRequest instead.

What is the best way to prevent errors in n8n Code node JavaScript?

The best way to prevent errors in n8n Code node JavaScript is to apply robust validation patterns and safe data access methods using $input.all() and $input.first() for consistent workflow results.

Does this approach work for complex data transformations in n8n?

Yes, this approach works for complex data transformations in n8n by enforcing explicit data access and reliable return formatting across both All Items and Each Item execution modes for production environments.