n8n-code-javascript

Write correct n8n Code node JavaScript with proper input modes and output format.

Updated May 12, 2026
One-click install
npx skills add https://github.com/contenido-wq/aivi_core --skill n8n-code-javascript-contenido-wq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/contenido-wq/aivi_core/tree/main/.github/skills/n8n-code-javascript
Command: npx skills add https://github.com/contenido-wq/aivi_core --skill n8n-code-javascript-contenido-wq

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the confusion and workflow-breaking mistakes people make when writing JavaScript inside n8n Code nodes, especially around input mode selection, correct data access, and the required return format.

Core Features & Use Cases

  • Choose the right execution mode (All Items vs Each Item): Prevents logic errors and performance issues by guiding when to aggregate across items versus when to process items independently.
  • Use safe data access patterns: Covers $input.all(), $input.first(), $input.item, $node, and the critical webhook payload nesting under $json.body.
  • Avoid common Code node failures: Provides guardrails for the most frequent errors like missing returns, incorrect output wrapping, expression syntax misuse, unmatched escaping, and undefined property crashes.
  • Apply production-tested patterns and built-ins: Includes real transformation patterns plus a reference for $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and $getWorkflowStaticData().

Quick Start

Ask: “Explain how to correctly transform webhook POST items in an n8n Code node using Run Once for All Items, reading fields from $json.body, and returning results as [{json: {...}}].”

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 breaking the workflow?

To return data from an n8n Code node, you must format the output as an array of objects like [{json: {...}}]. Wrapping your transformed data in this required structure prevents workflow execution failures and ensures downstream nodes receive valid items.

Why does my n8n webhook payload show as undefined in the Code node?

Webhook payloads in n8n are nested, so you must access data via $json.body instead of the root object. Using this safe data access pattern prevents undefined property crashes when processing incoming POST requests inside your Code node.

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

Use Run Once for All Items when you need aggregations across multiple items, and Each Item for independent per-item validations. Choosing the correct execution mode prevents logic errors and performance issues during data transformation.

Can I use Luxon and JMESPath inside n8n JavaScript Code nodes?

Yes, n8n Code nodes support built-in helpers including DateTime from Luxon for date manipulation and $jmespath() for JSON querying. You can also use $helpers.httpRequest() for API calls to enhance your transformation workflows.

What is the best way to avoid common JavaScript errors in n8n workflows?

The best way to avoid n8n JavaScript errors is to use production-tested patterns that prevent missing returns, incorrect output wrapping, and expression syntax misuse. Applying these guardrails ensures your workflows execute reliably without unmatched escaping issues.