n8n-code-javascript

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

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/Sebasarmas19/Chatbot-Reminder --skill n8n-code-javascript-sebasarmas19
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/Sebasarmas19/Chatbot-Reminder/tree/main/n8n-skills/skills/n8n-code-javascript
Command: npx skills add https://github.com/Sebasarmas19/Chatbot-Reminder --skill n8n-code-javascript-sebasarmas19

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing JavaScript in n8n Code nodes causes frequent failures from wrong return formats, confused expression syntax, and mishandled webhook data, and this Skill provides the patterns and references to avoid those errors. ## Core Features & Use Cases - Data Access Patterns: Covers $input.all(), $input.first(), $input.item, and $node references, including the critical webhook .body nesting gotcha. - Production Patterns: Provides 10 tested patterns such as multi-source aggregation, regex filtering, CRM transformation, and Slack Block Kit formatting. - Error Prevention: Documents the top 5 Code node errors (missing return, {{ }} syntax confusion, wrong return wrapper, unmatched brackets, missing null checks) with fixes. - Built-in Functions Reference: Details $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and $getWorkflowStaticData(). - Use Case: When building an n8n workflow that aggregates API responses and sends a formatted Slack report, use this Skill to write the Code node correctly on the first attempt. ## Quick Start Ask the AI to write an n8n Code node in JavaScript that processes webhook data and returns properly formatted items.

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 in an n8n Code node with JavaScript?

Use $input.all() to process 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.fieldName.

What return format does the n8n Code node require?

The Code node 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 fields via $json.body.name or extract the body first with const data = $input.first().json.body.

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, and use template literals with backticks for string interpolation.

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 way to call APIs directly from code.

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

Use a Code node for complex transformations, multi-step logic, aggregations, or recursive operations. For simple field mapping, filtering, or conditionals, the Set, Filter, IF, or Switch nodes are more appropriate.