n8n-code-python

Write Python code in n8n Code nodes with correct return formats.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/BoraPerusic/agents --skill n8n-code-python-boraperusic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/BoraPerusic/agents/tree/main/skills/to%20try/n8n-code-python
Command: npx skills add https://github.com/BoraPerusic/agents --skill n8n-code-python-boraperusic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides structured guidance for writing Python code within n8n Code nodes, helping developers leverage Python when necessary while using n8n's native helpers and patterns.

Core Features & Use Cases

  • Clear guidance on when to choose Python (Beta) vs Python (Native) in n8n Code nodes.
  • Best practices for data access patterns (_input.all(), _input.first(), _node) and safe dictionary access with .get().
  • Real-world use cases including webhook payload handling, per-item vs all-items execution modes, and safe return formats.

Quick Start

Drop Python code into an n8n Code node to process inputs and return the required json payload.

Frequently Asked Questions about n8n-code-python

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

FAQPage Schema
How do I write Python code in n8n Code nodes to transform input data?

To write Python code in n8n Code nodes, use best-practice patterns like _input.all() and _input.first() to access items, then return the transformed data in the correct JSON format. Safe dictionary access with .get() prevents key errors.

What is the correct return format for Python Code nodes in n8n?

The correct return format for Python Code nodes in n8n requires returning a JSON payload. You must structure outputs properly when processing multiple items, single items, or webhook payloads to ensure downstream nodes receive valid data.

Should I use Python Beta or Python Native mode in n8n Code nodes?

Choosing between Python Beta and Python Native modes in n8n Code nodes depends on your environment. The skill provides guidance on selecting the appropriate mode based on your specific data processing and webhook handling requirements.

How do I safely access webhook payload data in n8n Python Code nodes?

To safely access webhook payload data in n8n Python Code nodes, use dictionary .get() methods and understand the webhook body structure. This prevents runtime errors when keys are missing or payloads vary across requests.

Can I process multiple items individually in an n8n Python Code node?

Yes, you can process multiple items individually in an n8n Python Code node using per-item execution mode. This approach applies transformations to each item separately, contrasting with all-items mode which handles the entire dataset at once.

Why does my n8n Python Code node fail when accessing missing dictionary keys?

An n8n Python Code node fails on missing keys because direct dictionary access throws errors. Using the .get() method for safe dictionary access returns None or a default value instead, preventing workflow interruptions.