n8n-code-javascript

Write n8n Code node JavaScript with correct return formats and input access patterns.

6|1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/kmshihab7878/claude-code-setup --skill n8n-code-javascript-kmshihab7878
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/kmshihab7878/claude-code-setup/tree/main/skills/n8n/czlonkowski/skills/n8n-code-javascript
Command: npx skills add https://github.com/kmshihab7878/claude-code-setup --skill n8n-code-javascript-kmshihab7878

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many developers make subtle mistakes when authoring JavaScript inside n8n Code nodes—wrong return formats, misuse of expression syntax, improper webhook body access, and fragile null handling—that break workflows or produce silent failures. This skill consolidates best practices, clear access patterns, error-prevention techniques, and built-in helper usage so scripts run reliably in production automation pipelines.

Core Features & Use Cases

  • Data access patterns: Clear guidance on when to use $input.all(), $input.first(), and $input.item and how to reference other node outputs safely.
  • Return format & error prevention: Rules and examples ensuring code returns arrays of {json} objects, plus guard clauses, optional chaining, and try/catch patterns.
  • Built-ins & production patterns: Practical recipes using $helpers.httpRequest, DateTime (Luxon), $jmespath, static storage, and 10 production-tested coding patterns for aggregation, parsing, ranking, and reporting.
  • Use Case: Parse a webhook payload, normalize and deduplicate items, call external APIs for enrichment, and return a validated array for downstream nodes.

Quick Start

Use the n8n-code-javascript skill to convert an incoming webhook payload into a validated, normalized array of items and return them in the required [{json:{}}] format.

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 without breaking the workflow, you must return an array of objects formatted as [{json:{}}]. Following this structured return format ensures downstream nodes correctly parse your JavaScript output.

What is the correct way to access incoming items in an n8n Code node?

Access incoming items in an n8n Code node using $input patterns like $input.all() for batch mode or $input.first() for single items. Using these built-in access methods prevents reference errors during workflow automation.

How do I parse a webhook payload and normalize items in n8n?

Parse a webhook payload and normalize items in n8n by applying JavaScript data transformation techniques inside the Code node. Validate inputs with null checks and optional chaining to deduplicate data before returning the array.

Can I use Luxon DateTime and JMESPath inside n8n Code node scripts?

Yes, you can use Luxon DateTime and JMESPath inside n8n Code node scripts through built-in helpers. These built-ins allow you to handle date formatting and query JSON data directly within your automation workflow.

What's the best way to handle errors and null values in n8n JavaScript automation?

Handle errors and null values in n8n JavaScript automation by implementing guard clauses, optional chaining, and try/catch patterns. These error-prevention techniques stop silent failures in production workflow pipelines.

How do I call external APIs for data enrichment using n8n Code nodes?

Call external APIs for data enrichment in n8n Code nodes by utilizing the $helpers.httpRequest built-in method. This function allows your JavaScript script to fetch external data and return validated arrays for downstream nodes.