n8n-code-python

Clarify Python usage in n8n Code nodes with standard library and return formats.

6.0k|1.0k|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/czlonkowski/n8n-skills --skill n8n-code-python-czlonkowski
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/czlonkowski/n8n-skills/tree/main/skills/n8n-code-python
Command: npx skills add https://github.com/czlonkowski/n8n-skills --skill n8n-code-python-czlonkowski

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill clarifies how to use Python inside n8n Code nodes, addressing the external-library limitation and the need for reliable data handling, mode selection, and return formats.

Core Features & Use Cases

  • Standard library-only guidance: Learn which modules are available and how to safely apply them.
  • Mode and data access clarity: Understand All Items vs. Each Item modes and how to access webhook payloads under body.
  • Error-prevention best practices: Use .get() for dictionary access and safe list indexing to avoid common KeyError/IndexError.
  • Return-format discipline: Ensure outputs are a list of objects with a json key, suitable for downstream nodes.
  • Real-world patterns: Apply common Python patterns for data transformation, validation, and simple analytics within Code nodes.

Quick Start

In a Python Code node, read input with _input.all(), apply a simple transformation (e.g., add a "processed" flag and timestamp) and return a properly formatted array of items.

Frequently Asked Questions about n8n-code-python

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

FAQPage Schema
Can I use external Python libraries in n8n Code nodes?

External Python libraries cannot be used in n8n Code nodes. Python execution is restricted to the standard library only, so you must rely on built-in modules for data transformation and apply safe practices like .get() for dictionary access.

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

Webhook payloads in an n8n Python Code node are accessed under the _json['body'] structure. You extract incoming data from this dictionary, apply your standard library transformations, and ensure the output is formatted as a list of objects with a json key.

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

The correct return format for n8n Python Code nodes is a list of objects, where each object contains a json key. Maintaining this return-format discipline ensures downstream nodes can properly consume the transformed data items.

Should I use Python or JavaScript for HTTP calls in n8n?

JavaScript is preferred over Python for HTTP calls and advanced data tasks in n8n. Because Python is limited to the standard library, complex network requests or advanced integrations are better handled using JavaScript within the Code node.

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

To process multiple items in an n8n Python Code node, use batch processing with _input.all() for All Items mode, or handle records individually with _input.item for Each Item mode. Both methods allow safe data transformation using standard library modules.