n8n-code-python

Explain Python coding in n8n Code nodes using only the standard library.

1|Updated Dec 20, 2025
One-click install
npx skills add https://github.com/ditchallaway/Robotic-Property-Photographer --skill n8n-code-python-ditchallaway
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/ditchallaway/Robotic-Property-Photographer/tree/main/.agents/skills/n8n-code-python
Command: npx skills add https://github.com/ditchallaway/Robotic-Property-Photographer --skill n8n-code-python-ditchallaway

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Python code in n8n Code nodes is constrained by a no-external-libraries policy and strict data-access patterns; this guide explains how to work within those limits to build robust data transformations.

Core Features & Use Cases

  • Data access patterns overview: _input.all(), _input.first(), _input.item, and _node references.
  • Safe data handling and webhook payload access via _json["body"].
  • Return format enforcement: always return [{"json": {...}}], with examples for single and multi-item outputs.
  • Best practices for error handling, mode selection, and using standard library modules.

Quick Start

Create a Python Code node, select the Run Once for All Items mode, and implement a transformation using only the Python standard library with safe dictionary access.

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 in n8n Code nodes for data transformation?

To write Python in n8n Code nodes for data transformation, use the standard library only and access input data via patterns like _input.all() or _input.first(), then return results as a list of dictionaries with a json key.

Can I use external Python libraries in n8n Code nodes?

No, you cannot use external Python libraries in n8n Code nodes. The environment enforces a strict no-external-libraries policy, meaning you must build your data transformations using only the built-in Python standard library.

What is the correct return format for Python code in n8n?

The correct return format for Python code in n8n is a list of dictionaries containing a json key, such as [{"json": {...}}]. Enforcing this safe return format ensures n8n properly processes both single and multi-item outputs.

How do I access webhook payloads in n8n Python Code nodes?

To access webhook payloads in n8n Python Code nodes, use safe dictionary access patterns like _json["body"]. This ensures secure extraction of incoming webhook data for downstream processing within the standard library constraints.

What are the limitations of using Python in n8n workflows?

The main limitations of using Python in n8n workflows are the strict no-external-libraries policy and constrained data-access patterns. You must rely entirely on the standard library and handle errors carefully within the Run Once for All Items or per-item modes.

When should I use Run Once for All Items mode in n8n Python Code?

Use Run Once for All Items mode in n8n Python Code when you need to process batch data transformations across the entire input array at once. This mode allows you to apply standard library logic to multiple items simultaneously before returning the formatted output.