n8n-code-python

Write Python code patterns for n8n Code nodes using _input and _json.

Updated Mar 28, 2026
One-click install
npx skills add https://github.com/baselakkad585-maker/basel-dev-skills --skill n8n-code-python-baselakkad585-maker
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/baselakkad585-maker/basel-dev-skills/tree/main/skills/n8n-code-python
Command: npx skills add https://github.com/baselakkad585-maker/basel-dev-skills --skill n8n-code-python-baselakkad585-maker

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Write Python code inside n8n Code nodes while leveraging n8n helper syntax (_input, _json, _node) and staying within the constraints of the Python Standard Library.

Core Features & Use Cases

  • Provides practical patterns for reading, transforming, and returning data in Code nodes using _input/_json and deterministic list-of-dictionaries output.
  • Emphasizes using only standard library modules, safe dictionary access with .get(), and proper handling of webhook payloads (data under body).
  • Covers common n8n integration scenarios such as data transformation, aggregation, and per-item processing with explicit return formats.

Quick Start

Provide a minimal Python example that reads all items from _input, processes them, and returns a list of dictionaries with a json key.

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 process webhook data?

To write Python in n8n Code nodes, access webhook payloads under the body key and use _input or _json to read data. Return a deterministic list of dictionaries with a json key to ensure safe outputs.

Can I use external Python libraries in n8n Code nodes?

No, n8n Code nodes restrict Python to the standard library only. You must avoid external imports and unsafe operations, relying on standard modules for data transformation and aggregation tasks.

What is the correct return structure for Python code in n8n?

The correct return structure for Python in n8n is a list of dictionaries containing a json key. This deterministic format ensures downstream nodes properly parse the transformed data from your Code node.

How do I access item data inside an n8n Python Code node?

Access item data inside an n8n Python Code node using _input and _json variables. Use safe dictionary access methods like .get() to handle missing keys and prevent runtime errors during per-item processing.

Why does my Python Code node fail when processing multiple items in n8n?

Python Code nodes fail if the return structure is incorrect or if code uses external imports. Ensure you return a deterministic list of dictionaries with a json key and use only the standard library.

Does n8n support Python for data transformation and aggregation?

Yes, n8n supports Python for data transformation and aggregation within Code nodes. You can leverage n8n helper syntax like _input and _node while using standard library modules to process items explicitly.