n8n-code-python

Guide Python code in n8n Code nodes with correct data access and return structure.

84|23|Updated May 6, 2026
One-click install
npx skills add https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack --skill n8n-code-python-morrislu-taipei
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack/tree/main/skills/_vendor/n8n-code-python
Command: npx skills add https://github.com/MorrisLu-Taipei/TigerAI-n8n-Skill-Pack --skill n8n-code-python-morrislu-taipei

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents failed n8n executions caused by common Python Code-node mistakes by teaching the correct input access patterns, return format, webhook payload structure, and the “no external libraries” constraint.

Core Features & Use Cases

  • No-external-libraries guardrail: Avoids ModuleNotFoundError by making it clear which standard-library modules are available and when to switch to JavaScript or n8n built-in nodes.
  • Correct data access in Python Code nodes: Guides users on using _input.all(), _input.first(), _input.item, and _node references (and clarifies webhook data nesting under _json["body"]).
  • Reliable output formatting & error prevention: Ensures Code nodes always return data in the required [{"json": {...}}] structure and explains how to avoid KeyError, IndexError, and missing-return failures.

Quick Start

Ask the AI: "I’m writing a Python Code node in n8n—how do I safely read webhook data from _json['body'], process multiple items using _input.all(), and return results as [{'json': ...}] without using external libraries?"

Frequently Asked Questions about n8n-code-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent ModuleNotFoundError when running Python code in n8n?

To prevent ModuleNotFoundError in n8n Python Code nodes, use only standard-library modules. External libraries are not supported, so switch to JavaScript or built-in n8n nodes if you need third-party packages.

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

Access webhook payload data in n8n Python Code nodes by referencing `_json['body']`. Webhook payloads are nested under the body key, preventing KeyError when extracting incoming request data for processing.

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

The correct return format for n8n Python Code nodes is a list of dictionaries like `[{'json': {...}}]`. Ensuring this exact structure prevents missing-return failures and allows downstream nodes to parse data correctly.

How do I process multiple items in an n8n Python Code node?

Process multiple items in n8n Python Code nodes using `_input.all()` to retrieve all input items. Use `_input.first()` or `_input.item` for single-item access, preventing IndexError during data transformation.

Why does my n8n Python Code node fail with a KeyError?

n8n Python Code nodes fail with a KeyError when accessing missing dictionary keys. Prevent this by validating data existence and using correct `_input` and `_node` references before extracting values for data parsing.

Can I use pandas for data transformation in an n8n Python Code node?

You cannot use pandas in n8n Python Code nodes because external libraries cause ModuleNotFoundError. Use standard-library-only modules for data transformation, or switch to JavaScript or built-in n8n nodes for advanced processing.