n8n-code-python

Write standard-library Python for n8n Code nodes with safe data access.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/FredrickDickson/course-connect --skill n8n-code-python-fredrickdickson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/FredrickDickson/course-connect/tree/main/.agents/skills/n8n-code-python
Command: npx skills add https://github.com/FredrickDickson/course-connect --skill n8n-code-python-fredrickdickson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python support in n8n Code nodes is limited to the standard library and must avoid external dependencies, making it safer to perform data transformations without network calls or heavy libraries.

Core Features & Use Cases

  • Uses data access patterns like _input.all(), _input.first(), and _input.item to work with batch or per-item data.
  • Webhook data is commonly found under the body key in _json, preventing KeyError from direct top-level access.
  • Returns must follow the n8n format: an array of objects each containing a json field.
  • Provides guidance on safe, production-ready Python code using only the standard library (json, datetime, re, base64, hashlib, urllib.parse, etc.).

Quick Start

Open a Python Code node, process all input items with _input.all(), and return a list of results wrapped as json dictionaries.

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 in n8n Code nodes using only the standard library?

To run Python in n8n Code nodes, use only the standard library for data transformation and parsing. Access batch or per-item data via _input.all() or _input.item, then return results as a list of items wrapped in {"json": ...} dictionaries.

Why does my n8n Python Code node throw a KeyError when accessing webhook payload data?

Accessing webhook payload data directly causes a KeyError because the data is nested under the body key in _json. Use safe dictionary access with .get() to retrieve values from the body key and prevent runtime errors in your n8n Code node.

What format should Python Code node return in n8n?

The Python Code node in n8n must return an array of objects, with each object containing a json field. Wrap your transformed data as {"json": ...} inside a list to ensure n8n processes the output correctly across subsequent workflow nodes.

Can I use external Python dependencies in n8n Code nodes?

You cannot use external Python dependencies in n8n Code nodes. The environment is restricted to the standard library, including modules like json, datetime, re, base64, hashlib, and urllib.parse, ensuring safe execution without network calls or heavy libraries.

What is the best way to handle per-item data transformation in n8n Python scripts?

The best way to handle per-item data transformation in n8n Python scripts is using _input.item for individual items or _input.all() for batch processing. Apply standard library functions for parsing and return the results as a list of json-wrapped dictionaries.