n8n-code-python

Write Python in n8n Code nodes using standard library and required return formats.

Updated Jan 27, 2026
One-click install
npx skills add https://github.com/Brmbobo/Lead-Gen --skill n8n-code-python-brmbobo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/Brmbobo/Lead-Gen/tree/main/.claude/skills/n8n-code-python
Command: npx skills add https://github.com/Brmbobo/Lead-Gen --skill n8n-code-python-brmbobo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill clarifies how to write Python inside n8n Code nodes, including safe data access patterns, the constraint of using only the standard library, and the required return format.

Core Features & Use Cases

  • Data access guidance: learn when to use _input.all(), _input.first(), or _input.item and how to correctly retrieve webhook data from _json["body"].
  • Library constraints: understand that external libraries are not available and you should rely on the Python standard library.
  • Return discipline: ensure outputs follow the mandated structure of a list of objects with a json key across all code paths.
  • Error prevention: overview of common mistakes and proven patterns to avoid KeyError, IndexError, and unsafe returns.

Quick Start

Run a Python Code node that reads all input items, appends a processed timestamp, and returns the transformed items in the required format.

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 inside an n8n Code node safely?

To run Python inside an n8n Code node safely, use standard library functions only, access input data via _input.all() or _input.item, and strictly return a list of objects containing a json key.

Can I use external Python packages in n8n Code nodes?

No, you cannot use external Python packages in n8n Code nodes. You are constrained to using only the Python standard library for data transformation, parsing, and lightweight computation tasks.

How do I access webhook data in an n8n Python Code node?

Access webhook data in an n8n Python Code node by retrieving it from the _json["body"] attribute. This ensures safe data access when processing incoming webhook payloads.

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

The required return format for Python Code nodes in n8n is a list of objects, where each object contains a json key. Maintaining this return return discipline across all code paths prevents common output errors.

Why does my n8n Python code throw a KeyError or IndexError?

Your n8n Python code throws a KeyError or IndexError due to unsafe data access patterns. Prevent these common errors by applying proven guidance for safely retrieving items and webhook data.