n8n-code-javascript

Transform input items with JavaScript in n8n Code nodes.

52|6|Updated Nov 24, 2025
One-click install
npx skills add https://github.com/ovachiever/droid-tings --skill n8n-code-javascript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/ovachiever/droid-tings/tree/main/skills/n8n-code-javascript
Command: npx skills add https://github.com/ovachiever/droid-tings --skill n8n-code-javascript

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guides how to write robust JavaScript in n8n Code nodes, avoid common errors, and leverage built-in helpers.

Core Features & Use Cases

  • Data access patterns ($input.all, $input.first, $input.item)
  • Common production patterns for transformations, aggregations, and error handling
  • Built-in functions overview (http requests, DateTime, JSON querying)
  • Debugging and CI considerations for code nodes

Quick Start

Start by using the provided patterns to implement a small data transformation in a Code node.

Frequently Asked Questions about n8n-code-javascript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I transform data using JavaScript in n8n Code nodes?

JavaScript Code nodes in n8n transform input items by accessing data via $input.all, $input.first, or $input.item(), then returning an array of {json: ...} objects. Use $helpers.httpRequest for HTTP calls, DateTime (Luxon) for date operations, and $jmespath for JSON querying. The node runs in either Run Once for All Items or Run Once for Each Item mode depending on your batch requirements.

What are common patterns for data aggregation and filtering in n8n Code nodes?

Production patterns include mapping and filtering input arrays, aggregating values across items, and enriching data with external API responses. Access inter-node data through $node references and webhook payloads via .body. Use error prevention patterns and safe data access to avoid runtime failures in batch processing workflows.

Can I make HTTP requests directly from n8n Code nodes?

Yes, $helpers.httpRequest enables cross-node HTTP requests within Code nodes for fetching external data or calling APIs. Combine this with data transformation logic to enrich items, validate against external sources, or aggregate responses—all within a single code node without separate HTTP Request nodes.

How do I handle webhook payloads in n8n Code nodes?

Webhook payloads are accessed through the .body property within Code nodes. Extract and transform webhook data using standard JavaScript, then reference it alongside other node outputs via $node. This enables parsing incoming webhooks, filtering fields, and routing the transformed payload downstream.

What's the difference between Run Once for All Items and Run Once for Each Item modes?

Run Once for All Items processes the entire input batch in a single execution, accessed via $input.all(), enabling aggregation and cross-item operations. Run Once for Each Item executes the code separately for each input item using $input.item(), ideal for per-item transformations and API enrichment at scale.

How do I debug JavaScript errors in n8n Code nodes?

Use error prevention patterns documented in the Skill—validate data before access, handle null/undefined safely, and test transformations incrementally. The Skill covers CI considerations and debugging practices to catch issues before production deployment in workflows.