n8n-code-javascript

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

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

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 mistakes, and missing null checks, causing workflow execution 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. - Error Prevention: Documents the top 5 Code node errors covering over 60% of failures, with wrong-vs-right examples and a prevention checklist. - Built-in Functions Reference: Details $helpers.httpRequest(), DateTime (Luxon), $jmespath(), and $getWorkflowStaticData() usage. - Use Case: When building a workflow that aggregates data from multiple APIs and formats a Slack report, use this Skill to write correct Code node JavaScript with proper return format and null-safe access. ## Quick Start Ask the AI to write JavaScript for an n8n Code node that processes webhook data and returns formatted 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 access data in an n8n Code node?

Use $input.all() to process all items as an array, $input.first() for single-item operations, or $input.item in Run Once for Each Item mode. Access fields via the .json property, such as $input.first().json.fieldName.

What return format does the 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 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 the body first before processing fields.

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. Code nodes use plain JavaScript, so write $json.field directly or 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 from code.

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 conditionals, the Set, Filter, IF, or Switch nodes are more appropriate.