n8n-code-javascript

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

1|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/JulioBorges/ag-n8n-skills --skill n8n-code-javascript-julioborges
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/JulioBorges/ag-n8n-skills/tree/main/.agent/.skills/n8n-automation
Command: npx skills add https://github.com/JulioBorges/ag-n8n-skills --skill n8n-code-javascript-julioborges

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers to write reliable JavaScript inside n8n Code nodes by enforcing safe data access, correct webhook handling, and the required [{json: {...}}] return shapes, reducing common runtime and configuration errors.

Core Features & Use Cases

  • Guided data access: use $input.all(), $input.first(), and $input.item correctly across Run Once for All Items and Run Once for Each Item modes.
  • Safe webhook handling: access payloads under the correct .body path and avoid brittle direct root access.
  • Return shape enforcement: ensure code outputs conform to the required array of objects with json payloads.
  • Built-ins and patterns: leverage $helpers.httpRequest(), DateTime (Luxon), and $jmespath() for common transformation and integration tasks.
  • Production-ready guidance: avoid common pitfalls, validate code against production patterns, and structure workflows for reliability.

Quick Start

Use the quick-start guidance to structure Code node logic, choose the appropriate execution mode, and produce outputs in the canonical [{json: {...}}] format without manual formatting pitfalls.

This skill helps developers write clean, maintainable, and production-ready JavaScript in n8n Code nodes by codifying best practices and common patterns.

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 a format error?

To return data from an n8n Code node correctly, you must output an array of objects using the exact [{json: {...}}] return shape. This structure ensures your JavaScript output passes validation and routes cleanly to downstream workflow nodes.

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

To access webhook payload data safely in an n8n Code node, retrieve values under the correct .body path rather than brittle direct root access. This safe data access pattern prevents runtime errors when handling incoming HTTP requests.

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

The difference between Run Once for All Items and Run Once for Each Item in n8n JavaScript is how data is accessed: use $input.all() for the entire dataset or $input.item() for individual records. Selecting the correct execution mode ensures proper data aggregation.

Can I make HTTP requests directly within n8n Code node JavaScript?

Yes, you can make HTTP requests directly within n8n Code node JavaScript by leveraging the built-in $helpers.httpRequest() method. This allows you to perform API calls and data integrations without leaving the code environment.

What built-in libraries are available for time handling in n8n Code nodes?

For time handling in n8n Code nodes, the built-in DateTime object from Luxon is available for date manipulation. You can also use $jmespath() to query and transform JSON data structures within your JavaScript logic.

Why does my n8n Code node JavaScript fail when processing multiple items?

Your n8n Code node JavaScript fails when processing multiple items if you use incorrect data access methods or fail to output the required array of objects with json payloads. Enforcing proper return shapes and mode selection resolves these runtime errors.