Skip to content

Part of Build n8n Workflows With Proven Patterns

Engineering Blueprint

Write Code in n8n Code Nodes

0June 2026

Write JavaScript and Python in n8n Code nodes with correct data access patterns, built-in functions, error handling, and the distinct Code Tool contract.

What problem does this solve?

Teaches Claude the correct data access patterns for Code nodes ($input.all(), $input.item in JavaScript; _input, _json in Python), the critical webhook .body gotcha, correct return format, built-in functions (this.helpers for HTTP, DateTime), Python standard library limitations (no external packages), and the Code Tool node's completely different contract (string return, query input, no $input), so Code nodes run first time instead of failing with "No execution data available" or wrong return format errors.

How does it work?

When you ask to write code in a Code node, this skill activates and shows: for JavaScript, use $input.all() for All Items mode and $input.item for Each Item mode; access webhook data via $json.body.field; return format must be [{json: {...}}]; use this.helpers.httpRequest() for HTTP calls (bare $helpers is undefined in task-runner sandbox). For Python, use _input and _json similarly; accept that no external libraries are available (use standard library: json, datetime, re, etc.); return the same format. For Code Tool (the distinct node attached to AI agents), return a string, not [{json}], and use query (JS) / _query (Python) for input. The skill includes 10 production-tested patterns and top error catalogs (10 patterns cover 62%+ of failures).

Included Skills

No skills in this group

What's required to run this?

Code nodes run in a sandboxed VM with per-invocation setup cost (500-1000ms cold start, amortizes on warm runs); a Code node is roughly 3x slower per-item than an expression for the same logic. Python Code nodes have no external library access (requests, pandas, numpy blocked); JavaScript is recommended for 95% of use cases. Code Tool sandbox has no $input, $helpers, $json, $getWorkflowStaticData access. It's a different environment entirely. The $helpers global in task-runner sandbox is undefined; use this.helpers instead.

Key Features

JavaScript Data Access

$input.all(), $input.item(), $input.first() with correct return [{json: {...}}]

Python Data Access

_input, _json, _node with same return format; standard library only

Critical Webhook Gotcha

Webhook data is under $json.body in both JavaScript and Python

Code Tool Node

Completely different contract: return string, use query input, no $input access

Built-in Functions

this.helpers.httpRequest(), DateTime, $jmespath(); what's available in each mode

About This Blueprint

Industry
Technology
1 File
Productivity

Business Automation & Productivity Workflow

Reduce hours lost to repetitive admin without adding a complicated stack. Prioritized, tested workflows automate routine research, client communication, project tracking, and website tasks while keeping people in control of important decisions.

1 File
Engineering

Business Technology & Digital Solutions Workflow

Avoid costly, fragmented digital projects with a plan that connects business goals to practical tools, implementation steps, and measurable results. It also flags performance, security, accessibility, and SEO checks before launch.

WordPressGoogle AnalyticsGoogle Search Console+2 more
Sales

ICP-Filtered Outreach Lists from G2 Buyer Intent

Stop wasting rep time on weak intent signals and mismatched accounts. The workflow ranks ICP-fit buyers by readiness, finds the right contact, and supplies tailored outreach angles for the strongest opportunities.

ClaudeClaudeG2 Buyer Intent (G2 MCP Server)ZoomInfo (MCP)+3 more

Ishani D.

Account Manager at G2