n8n-code-javascript

Transform data in n8n Code nodes using JavaScript helpers and safe access patterns.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/FredrickDickson/course-connect --skill n8n-code-javascript-fredrickdickson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/FredrickDickson/course-connect/tree/main/.agents/skills/n8n-code-javascript
Command: npx skills add https://github.com/FredrickDickson/course-connect --skill n8n-code-javascript-fredrickdickson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing JavaScript inside n8n Code nodes often leads to tangled data access, inconsistent return formats, and boilerplate error handling. This skill consolidates best practices for using $input, $json, and $node, with built-in helpers like $helpers.httpRequest and DateTime (Luxon) to enable reliable data transformations, API interactions, and webhook payload processing.

Core Features & Use Cases

  • Data access patterns: $input.all(), $input.first(), and $input.item for batch vs per-item logic.
  • Return format discipline: always return an array of objects with a json field, and ensure webhook payloads are accessed via .body when applicable.
  • Built-in helpers: use $helpers.httpRequest() for API calls, DateTime for date/time operations, and $jmespath() for JSON querying.
  • Production patterns: apply common patterns such as multi-source aggregation, top-N filtering, transformation, and reporting.
  • Debugging and safety: utilize console logging, try-catch, and null checks to produce robust workflows.

Quick Start

Process the input data with a single run over all items, apply a transformation, and return an array of JSON-wrapped results.

Frequently Asked Questions about n8n-code-javascript

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

FAQPage Schema
How do I process webhook payloads in n8n Code nodes?

To process webhook payloads in n8n Code nodes, access the incoming data strictly via the `.body` property and use `$input.all()` for batch processing. Return an array of objects containing a `json` field to ensure the output matches n8n's expected data structure.

What is the best way to structure JavaScript returns in n8n workflows?

The best way to structure returns in n8n workflows is to always return an array of objects where each object contains a `json` field. This strict return format prevents downstream node errors and ensures your data transformations integrate smoothly with the rest of the pipeline.

How do I make HTTP API calls inside an n8n Code node?

To make HTTP API calls inside an n8n Code node, use the built-in `$helpers.httpRequest()` helper function. This allows you to perform reliable API interactions directly within your JavaScript code without needing external nodes or custom boilerplate.

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

Use Run Once for All Items in n8n as the default workflow for batch data transformations and multi-source aggregation. Switch to Run Once for Each Item only when you need isolated, per-item logic, utilizing `$input.first()` or `$input.item` for specific data access.

How do I handle date and time transformations in n8n JavaScript?

To handle date and time transformations in n8n JavaScript, use the built-in `DateTime` object provided by the Luxon library. This allows you to perform robust date parsing, formatting, and arithmetic operations directly within your Code node transformations.

Why does my n8n Code node data transformation fail on null values?

n8n Code node data transformations often fail on null values due to unhandled data access. Implement null checks, use try-catch blocks for error handling, and apply safe data access patterns with `$jmespath()` to query JSON and prevent workflow failures.