Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
Add this skill
npx mdskills install czlonkowski/n8n-code-javascriptComprehensive guide with production patterns, error prevention, and excellent coverage of common pitfalls
Expert guidance for writing JavaScript code in n8n Code nodes.
Teaches how to write effective JavaScript in n8n Code nodes, avoid common errors, and use built-in functions effectively.
Trigger keywords:
Common scenarios:
[{json: {...}}].bodyTop 5 errors to avoid:
{{}} in code)n8n-code-javascript/
├── SKILL.md (500 lines)
│ Overview, quick start, mode selection, best practices
│ - Mode selection guide (All Items vs Each Item)
│ - Data access patterns overview
│ - Return format requirements
│ - Critical webhook gotcha
│ - Error prevention overview
│ - Quick reference checklist
│
├── DATA_ACCESS.md (400 lines)
│ Complete data access patterns
│ - $input.all() - Most common (26% usage)
│ - $input.first() - Very common (25% usage)
│ - $input.item - Each Item mode (19% usage)
│ - $node - Reference other nodes
│ - Webhook data structure (.body nesting)
│ - Choosing the right pattern
│ - Common mistakes to avoid
│
├── COMMON_PATTERNS.md (600 lines)
│ 10 production-tested patterns
│ - Pattern 1: Multi-source Aggregation
│ - Pattern 2: Regex Filtering
│ - Pattern 3: Markdown Parsing
│ - Pattern 4: JSON Comparison
│ - Pattern 5: CRM Transformation
│ - Pattern 6: Release Processing
│ - Pattern 7: Array Transformation
│ - Pattern 8: Slack Block Kit
│ - Pattern 9: Top N Filtering
│ - Pattern 10: String Aggregation
│ - Pattern selection guide
│
├── ERROR_PATTERNS.md (450 lines)
│ Top 5 errors with solutions
│ - Error #1: Empty Code / Missing Return (38%)
│ - Error #2: Expression Syntax Confusion (8%)
│ - Error #3: Incorrect Return Wrapper (5%)
│ - Error #4: Unmatched Brackets (6%)
│ - Error #5: Missing Null Checks
│ - Error prevention checklist
│ - Quick error reference
│ - Debugging tips
│
├── BUILTIN_FUNCTIONS.md (450 lines)
│ Complete built-in function reference
│ - $helpers.httpRequest() API reference
│ - DateTime (Luxon) complete guide
│ - $jmespath() JSON querying
│ - $getWorkflowStaticData() persistent storage
│ - Standard JavaScript globals
│ - Available Node.js modules
│ - What's NOT available
│
└── README.md (this file)
Skill metadata and overview
Total: ~2,400 lines across 6 files
MOST COMMON MISTAKE: Webhook data is under .body
// ❌ WRONG
const name = $json.name;
// ✅ CORRECT
const name = $json.body.name;
CRITICAL: Must return array with json property
// ❌ WRONG
return {json: {result: 'success'}};
// ✅ CORRECT
return [{json: {result: 'success'}}];
Don't use {{}} in Code nodes
// ❌ WRONG
const value = "{{ $json.field }}";
// ✅ CORRECT
const value = $json.field;
{{}} in OTHER nodes{{}})search_nodes({query: "code"})get_node_essentials("nodes-base.code")validate_node_operation()Use Code node when:
Consider other nodes when:
Code node excels at: Complex logic that would require chaining many simple nodes
Before this skill:
After this skill:
$input.all(), $input.first(), $input.item[{json: {...}}] format.body property{{}} syntax: Use JavaScript directly5 test scenarios covering:
{{}})Each evaluation tests skill activation, correct guidance, and reference to appropriate documentation files.
Conceived by Romuald Członkowski - www.aiadvisors.pl/en
Part of the n8n-skills collection.
Install via CLI
npx mdskills install czlonkowski/n8n-code-javascriptN8n Code Javascript is a free, open-source AI agent skill. Write JavaScript code in n8n Code nodes. Use when writing JavaScript in n8n, using $input/$json/$node syntax, making HTTP requests with $helpers, working with dates using DateTime, troubleshooting Code node errors, or choosing between Code node modes.
Install N8n Code Javascript with a single command:
npx mdskills install czlonkowski/n8n-code-javascriptThis downloads the skill files into your project and your AI agent picks them up automatically.
N8n Code Javascript works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.