n8n-code-javascript

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

71|14|Updated Jun 26, 2025
One-click install
npx skills add https://github.com/Synaptic-Labs-AI/PACT-Plugin --skill n8n-code-javascript-synaptic-labs-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/Synaptic-Labs-AI/PACT-Plugin/tree/main/pact-plugin/skills/n8n-code-javascript
Command: npx skills add https://github.com/Synaptic-Labs-AI/PACT-Plugin --skill n8n-code-javascript-synaptic-labs-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing JavaScript inside n8n Code nodes can be error-prone due to ambiguous data access patterns, webhook payload structures, and strict return formatting. This Skill guides developers through safe data access, mode selection (All Items vs Each Item), error prevention, and best practices for building reliable Code Node scripts.

Core Features & Use Cases

  • Data access patterns: $input.all(), $input.first(), and $input.item usage with safe null checks.
  • Mode guidance: Run Once for All Items vs Run Once for Each Item with practical tradeoffs.
  • Return format enforcement: Always return an array of objects with a json property.
  • Webhook data gotcha: Access webhook payload under .body.
  • Built-ins overview: $helpers.httpRequest(), DateTime (Luxon), $jmespath() for data manipulation.

Quick Start

Process a batch of inputs, map them to a standardized json structure, and return the result.

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 access webhook data in an n8n Code node, extract the payload from the .body property of the input item. This specific data access pattern avoids undefined errors when processing incoming HTTP requests.

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

Choose Run Once for All Items in an n8n Code node for batch processing and data-rich transformations, or Run Once for Each Item for isolated per-item logic. Mode selection depends on your workflow's error handling needs.

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

To access webhook data in an n8n Code node, extract the payload from the .body property of the input item. This specific data access pattern avoids undefined errors when processing incoming HTTP requests.

Can I use Luxon DateTime and JMESPath in n8n JavaScript code?

Yes, n8n Code nodes support built-in JavaScript libraries including Luxon DateTime for time manipulation and $jmespath() for querying data. You can also use $helpers.httpRequest() for API interactions.

What is the safest way to access input items in n8n Code nodes?

The safest way to access input data in n8n Code nodes is using $input.all() for batches or $input.first() with safe null checks. This prevents runtime crashes when processing empty webhook payloads.