n8n-code-javascript

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

1|Updated Dec 20, 2025
One-click install
npx skills add https://github.com/ditchallaway/Robotic-Property-Photographer --skill n8n-code-javascript-ditchallaway
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/ditchallaway/Robotic-Property-Photographer/tree/main/.agents/skills/n8n-code-javascript
Command: npx skills add https://github.com/ditchallaway/Robotic-Property-Photographer --skill n8n-code-javascript-ditchallaway

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing robust JavaScript inside n8n Code nodes can be challenging due to subtle data-access rules, mode differences, and strict return requirements. This skill provides a clear, production-ready reference to safely access inputs, handle webhook data, and leverage built-in helpers and DateTime utilities while ensuring outputs conform to the required structure.

Core Features & Use Cases

  • Clear data-access patterns: $input.all(), $input.first(), and $input.item for different execution modes.
  • Safe integration with built-in helpers: $helpers.httpRequest for API calls and DateTime (Luxon) for time handling.
  • Guaranteed output format: always return an array of objects with a json property (e.g., [{json: {...}}]).
  • Webhook data safety: proper handling of nested data under .body and guard rails for nulls.
  • Comprehensive guidance: examples for common Code node scenarios, error prevention, and pattern best practices.

Quick Start

Process input from a previous node with $input.all(), apply standard JavaScript transformations, and return a single or multiple { json: {...} } objects as the final output.

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 return data from an n8n Code node safely, always structure your output as an array of objects containing a json property, such as [{ json: { ... } }]. This strict return format prevents execution errors and ensures downstream nodes receive valid data.

What is the correct way to access webhook data in an n8n Code node?

Accessing webhook data in an n8n Code node requires safely extracting nested payloads from the .body property. You should apply guardrails for null safety to handle missing fields before processing the incoming HTTP request data.

How do I process all items in an n8n Code node using JavaScript?

For batch processing all items in an n8n Code node, use the $input.all() method to access the full array of items. To handle a single item, use $input.first(), and for per-item execution modes, use $input.item.

Can I make HTTP requests inside an n8n Code node?

Yes, you can make HTTP requests inside an n8n Code node by utilizing the built-in $helpers.httpRequest function. This allows you to perform API calls directly within your JavaScript code while maintaining proper error handling.

Why does my n8n Code node fail when using expression syntax?

Your n8n Code node fails because expression syntax should not be used inside JavaScript code. You must avoid expression syntax entirely and rely on standard JavaScript data-access patterns and built-in helpers to prevent execution failures.