n8n-code-python

Write Python standard library code in n8n Code nodes with structured data access.

92|27|Updated Jan 16, 2026
One-click install
npx skills add https://github.com/WilkoMarketing/antigravity-n8n-skills --skill n8n-code-python-wilkomarketing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/WilkoMarketing/antigravity-n8n-skills/tree/main/n8n-code-python
Command: npx skills add https://github.com/WilkoMarketing/antigravity-n8n-skills --skill n8n-code-python-wilkomarketing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python development inside n8n Code nodes is constrained by no external libraries, strict data-flow rules, and the need for a consistent return structure. This guide explains how to write robust Python code that runs safely within Code nodes while respecting n8n's data-passing conventions.

Core Features & Use Cases

  • Standard library only environment: operate without external dependencies and leverage built-in modules like json, datetime, re, base64, hashlib, and more.
  • Data access patterns: use _input.all(), _input.first(), _input.item, and _node to compose batch, single-item, or cross-node workflows.
  • Webhook payload handling: correctly access webhook data via the body of the payload to avoid KeyError and misreads.
  • Consistent return format: always return a list of objects with a single json key, e.g. [{"json": {...}}], for downstream nodes.
  • Typical use cases: data transformation, validation, simple aggregations, and per-item processing within Code nodes.

Quick Start

Create a Python Code node, pull inputs with _input.all(), transform them, and return a properly formatted 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 without external libraries?

To write Python in n8n Code nodes, use only the Python standard library for data transformation and validation, leveraging built-in modules like json, datetime, re, and hashlib without external dependencies.

Why does my n8n Python code throw a KeyError when accessing webhook data?

A KeyError occurs when accessing webhook data incorrectly in n8n. To fix this, access the webhook payload data safely via the body property of the incoming payload to avoid misreads and missing keys.

How do I return data from an n8n Code node using Python?

Return data from an n8n Code node by outputting a list of dictionaries, each containing a single json key, such as [{"json": {...}}], ensuring downstream nodes can process the structured data correctly.

What is the best way to access input data in n8n Python Code nodes?

Access input data in n8n Python Code nodes using _input.all() for batch processing, _input.first() for single items, _input.item for per-item processing, and _node for cross-node workflow references.

Can I use external Python packages in n8n workflows?

You cannot use external Python packages in n8n workflows. The environment enforces a no-external-libraries constraint, requiring you to operate strictly with the Python standard library inside Code nodes.

What limitations exist when running Python in n8n?

Limitations of running Python in n8n include a strict no-external-libraries constraint and rigid data-flow rules, requiring standard library usage and consistent return formatting for workflow execution.