n8n-code-python

Write Python scripts in n8n Code nodes using _input and .get() patterns.

Updated Nov 29, 2025
One-click install
npx skills add https://github.com/thimslugga/agent-skills --skill n8n-code-python-thimslugga
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/thimslugga/agent-skills/tree/main/skills/development/n8n/n8n-code-python
Command: npx skills add https://github.com/thimslugga/agent-skills --skill n8n-code-python-thimslugga

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python in n8n Code nodes is bounded by strict limitations (no external libraries), strict return formats, and defined data access patterns, which can hinder effective automation scripting.

Core Features & Use Cases

  • Data access patterns with _input.all(), _input.first(), and _input.item for batch and per-item processing.
  • Webhook payload handling where data lives under the body key and must be accessed safely with .get().
  • Standard library usage for common tasks (json, datetime, re, base64, hashlib) without external dependencies.
  • Clear guidance on mode selection, return formats, and error-prevention patterns for reliable Code node scripts.

Quick Start

Create a Python Code node, read inputs with _input.all(), apply safe access with .get(), and return results as a list of objects each containing a json field.

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 safely?

To write Python in n8n Code nodes safely, use _input.all() or _input.first() for data access, apply .get() for safe dictionary lookups, and return results as a list of objects each containing a json key to prevent workflow errors.

Can I use external Python packages in n8n Code nodes?

No, you cannot use external Python packages in n8n Code nodes. You are restricted to the Python standard library, using built-in modules like json, datetime, re, base64, and hashlib for data transformation and lightweight processing tasks.

What is the required return format for Python scripts in n8n?

The required return format for n8n Python scripts is a list of items where each item is an object containing a json key. This strict structure ensures your Code node correctly passes the processed data downstream to subsequent workflow nodes.

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

To handle webhook payload data in n8n Python Code nodes, access the data under the body key and use safe dictionary access with .get() to extract values. This prevents runtime errors if expected keys are missing from the incoming webhook request.

Why does my Python script in an n8n Code node fail during data access?

Python scripts in n8n Code nodes fail during data access when standard dictionary syntax is used instead of safe access methods. Use _input.item or _input.all() patterns with .get() to avoid KeyErrors and ensure reliable workflow execution.

Does n8n support Python for batch processing in workflows?

Yes, n8n supports Python for batch processing in workflows using the Code node. You can process multiple items simultaneously by accessing the full dataset with _input.all() and returning a list of json objects for downstream automation.