n8n-code-python

Write Python code in n8n Code nodes using standard library only.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python code execution in n8n Code nodes is constrained by the absence of external libraries and by data-access nuances. This guide helps users understand how to write safe, practical Python code inside Code nodes, including safe data access, correct return formats, and when to prefer JavaScript.

Core Features & Use Cases

  • Learn to read and transform data using _input.all(), _input.first(), and _input.item.
  • Handle webhook payloads correctly via the body in _json and nested structures.
  • Ensure Code node outputs follow the required format with a list of {"json": ...} objects.
  • Get practical patterns for batch processing, per-item validation, and basic data processing with standard library only.

Quick Start

Write a simple Python Code node that reads all items, applies a transformation, and returns a list of items with a new 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 run Python code in an n8n Code node?

To run Python code in an n8n Code node, write standard library-only scripts using _input.all(), _input.first(), or _input.item to access data, then return a list of {"json": ...} objects for valid output.

Can I use external Python libraries inside n8n?

No, you cannot use external Python libraries inside n8n. Python execution in Code nodes is limited to the standard library only, meaning complex transformations requiring external packages are not supported.

How do I handle webhook payloads in n8n Python Code nodes?

To handle webhook payloads in n8n Python Code nodes, access incoming data via the body located in _json, navigating nested structures as needed before processing and returning the required list of json objects.

Why does my n8n Python Code node return an error?

Your n8n Python Code node returns an error typically due to KeyError, IndexError, missing returns, or wrong output formats. Python scripts must return a list of {"json": ...} objects and handle data access safely.

When should I use JavaScript instead of Python in n8n Code nodes?

You should use JavaScript instead of Python in n8n Code nodes for HTTP requests, date handling, or complex transformations, as JavaScript handles these operations more natively without standard library limitations.

What is the best way to process batch data with Python in n8n?

The best way to process batch data with Python in n8n is using _input.all() to read all items, applying your standard library transformations, and returning a properly formatted list of {"json": ...} objects.