n8n-code-javascript

Guide JavaScript coding in n8n Code nodes with data access and error prevention.

1|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/nirukk52/ContentEngine-AI-studio --skill n8n-code-javascript-nirukk52
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/nirukk52/ContentEngine-AI-studio/tree/main/.claude-skills/n8n-code-javascript
Command: npx skills add https://github.com/nirukk52/ContentEngine-AI-studio --skill n8n-code-javascript-nirukk52

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides users to write correct, safe JavaScript in n8n Code nodes, addressing common pitfalls like incorrect return formats, webhook data access, and missing null checks, so workflows run reliably.

Core Features & Use Cases

  • Code node data access: Learn to read data via $input.all(), $input.first(), and $input.item, and to reference other nodes with $node.
  • Built-in utilities: Use $helpers.httpRequest() for API calls and DateTime (Luxon) for date handling.
  • Error prevention: Understand and apply patterns that avoid common Code node errors and ensure robust workflows.
  • Use case example: Build a small data transformation that aggregates inputs, enriches them, and returns a consistent [{json: {...}}] payload.

Quick Start

Use the code node to read all items from the input, transform them, and return the results in the required [{json: {...}}] format. Example: const items = $input.all(); const processed = items.map(item => ({ json: { ...item.json, processed: true, timestamp: new Date().toISOString() }})); return processed;

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 errors?

To return data from an n8n Code node without errors, you must format your output as an array of objects using the exact [{json: {...}}] structure. This format ensures the workflow correctly parses your JavaScript payload for downstream processing.

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

To access webhook payload data in an n8n Code node, you must navigate the specific webhook body structure. Extracting values requires correctly referencing the webhook data object to avoid undefined errors during your workflow automation.

Can I make HTTP requests inside an n8n Code node using JavaScript?

Yes, you can make HTTP requests inside an n8n Code node by utilizing the built-in $helpers.httpRequest() method. This utility allows your JavaScript code to fetch external API data and integrate it directly into your workflow items.

What is the best way to handle date and time in n8n JavaScript?

The best way to handle date and time in n8n JavaScript is using the built-in Luxon DateTime library. It provides reliable DateTime parsing and manipulation within your Code nodes to ensure accurate timestamp transformations.

How do I read input items in an n8n Code node?

You read input items in an n8n Code node by using $input.all() to retrieve every item, $input.first() for the initial entry, or $input.item for the current iteration. You can also reference other nodes directly using $node.

Why does my n8n Code node fail when transforming multiple items?

Your n8n Code node likely fails when transforming multiple items due to missing null checks or an incorrect return format. Applying error-prevention patterns and enforcing the required [{json: {...}}] payload structure ensures robust workflow execution.