n8n-code-python

Write Python standard library code inside n8n Code nodes.

71|14|Updated Jun 26, 2025
One-click install
npx skills add https://github.com/ProfSynapse/PACT-Plugin --skill n8n-code-python-profsynapse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/ProfSynapse/PACT-Plugin/tree/main/pact-plugin/skills/n8n-code-python
Command: npx skills add https://github.com/ProfSynapse/PACT-Plugin --skill n8n-code-python-profsynapse

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill clarifies how to write Python inside n8n Code nodes while staying within the standard library and safe data access patterns, avoiding external libraries and common pitfalls.

Core Features & Use Cases

  • Safe data access using _input.all(), _input.first(), and _input.item to handle batch and per-item processing.
  • Webhook data handling with correct access through the body field and safe retrieval patterns for nested data.
  • Enforcing the required n8n return format: an array of objects each containing a json key: [{"json": {...}}].
  • Error prevention and best practices: safe dictionary access with .get(), guarded list indexing, and thorough testing across All Items and Each Item modes.
  • Standard library usage: leverage json, datetime, re, base64, hashlib, urllib.parse, math, random, statistics, and other built-ins without external packages.

Quick Start

Start with a simple transform of all input items using the safe patterns: read all items with _input.all(), apply a minimal transformation, and return the results wrapped as {"json": {...}}. Then consult DATA_ACCESS.md and ERROR_PATTERNS.md for safe access and error avoidance guidelines.

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 in n8n Code nodes without external libraries?

Writing Python in n8n Code nodes requires using only the standard library, leveraging built-ins like json, datetime, and re for data transformations. You must avoid external packages and use safe data access patterns to ensure production-ready workflows.

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

The required return format for n8n Code nodes is an array of objects, each containing a json key: [{"json": {...}}]. Enforcing this exact structure ensures your Python transformations output data correctly to downstream workflow nodes.

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

Safely accessing webhook data in n8n Python nodes involves retrieving payloads through the body field and using safe dictionary access with .get(). This prevents KeyError exceptions when handling missing or nested data in webhook payloads.

Can I use Python packages like pandas in n8n Code nodes?

You cannot use external Python packages like pandas in n8n Code nodes. The environment enforces standard library only usage, meaning you must rely on built-in modules such as json, math, statistics, and urllib.parse for data processing.

How do I handle batch versus per-item processing in n8n Python Code?

Batch and per-item processing in n8n Python Code nodes is handled using _input.all() for batch transformations and _input.item for per-item processing. Testing across All Items and Each Item modes ensures robust data access.

Why does my n8n Python code fail with a KeyError on missing data?

n8n Python code fails with KeyError when accessing missing dictionary keys directly. Prevent these errors by using .get() for safe dictionary access and guarded list indexing, ensuring robust handling of unpredictable input data structures.