n8n-code-javascript

Guides writing JavaScript in n8n Code nodes with data access patterns and error prevention.

Updated Aug 3, 2026
One-click install
npx skills add https://github.com/alvarocubacc/n8n-workflow-builder --skill n8n-code-javascript-alvarocubacc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/alvarocubacc/n8n-workflow-builder/tree/main/n8n-skills/skills/n8n-code-javascript
Command: npx skills add https://github.com/alvarocubacc/n8n-workflow-builder --skill n8n-code-javascript-alvarocubacc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing JavaScript in n8n Code nodes fails frequently due to incorrect return formats, confusion between expression syntax and JavaScript, webhook data nesting surprises, and missing null checks. This Skill provides the patterns and references needed to write correct Code node logic on the first attempt. ## Core Features & Use Cases - Data Access Patterns: Complete guidance on $input.all(), $input.first(), $input.item, and $node references, including the critical webhook .body nesting gotcha. - Production Patterns: Ten tested patterns covering multi-source aggregation, regex filtering, markdown parsing, CRM transformation, Slack Block Kit formatting, and top-N ranking. - Error Prevention: Covers the top five Code node errors (missing return statements, {{ }} expression misuse, wrong return wrapper, unmatched brackets, null access) with wrong-vs-right examples. - Built-in Functions Reference: Documents $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and $getWorkflowStaticData() with complete examples. - Use Case: When building an n8n workflow that aggregates data from multiple APIs and posts a ranked summary to Slack, use this Skill to write the transformation Code node correctly. ## Quick Start Ask the AI to write an n8n Code node in JavaScript that aggregates items from previous nodes and returns them sorted by score.

Frequently Asked Questions about n8n-code-javascript

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

FAQPage Schema
How do I access data from previous nodes in an n8n Code node?

Use $input.all() to get all items as an array, $input.first() for a single item, or $input.item when running in Each Item mode. Access fields through the .json property, for example $input.first().json.email.

What return format does an n8n Code node require?

Code nodes must return an array of objects where each object has a json property, in the format [{json: {...}}]. Returning a plain object or an array without the json wrapper causes validation errors.

Why is my webhook data undefined in the n8n Code node?

Webhook node output nests the payload under a body property, so $json.name returns undefined. Access the data via $json.body.name or extract const payload = $json.body first.

Can I use {{ }} expression syntax inside n8n Code nodes?

No, expression syntax with double curly braces only works in other nodes like Set or IF. Inside Code nodes, write plain JavaScript such as $json.field or template literals like `Hello ${$json.name}`.

How do I make HTTP requests from an n8n Code node?

Use the built-in $helpers.httpRequest() function with method, url, headers, and body options. External npm packages like axios are not available, so this helper is the supported approach for API calls.

When should I use a Code node instead of Set or IF nodes?

Use a Code node for complex transformations, multi-step logic, aggregations, or recursive operations. For simple field mapping, filtering, or single conditions, the Set, Filter, or IF nodes are simpler choices.