n8n-code-python

Writes Python for extracting data from n8n Code nodes with mc-multi-...

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/jaewilson07/comfy_mcp --skill n8n-code-python-jaewilson07
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/jaewilson07/comfy_mcp/tree/main/.github/skills/n8n-code-python
Command: npx skills add https://github.com/jaewilson07/comfy_mcp --skill n8n-code-python-jaewilson07

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill clarifies how to responsibly write Python code in n8n Code nodes by outlining the no-external-libraries constraint, standard library usage, and the required code output format, reducing common errors and misconfigurations.

Core Features & Use Cases

  • Learn to safely access data in Code nodes using _input.all(), _input.first(), _input.item and access webhook payloads via _json["body"].
  • Leverage Python's standard library (json, datetime, re, base64, hashlib, urllib.parse, math, random, statistics) for common transformations, validation, and lightweight analytics without external packages.
  • Use proven patterns (data transformation, filtering, aggregation, regex extraction) to build robust workflows inside n8n, with examples and best practices.

Quick Start

Create a Code node, import _input, and implement a small transformation that processes all items and returns a list of {"json": {...}} objects. Then consult the accompanying MD docs (DATA_ACCESS.md and COMMON_PATTERNS.md) for deeper patterns and caveats.

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 to transform data safely?

To write Python in n8n Code nodes safely, use standard library modules for data transformation and ensure your code returns an array of items containing a json key. Access input data securely using methods like _input.all() and _input.first().

Can I use external Python libraries inside n8n Code nodes?

No, you cannot use external Python libraries inside n8n Code nodes. You must rely exclusively on Python's built-in standard library, such as json, datetime, re, and hashlib, for data processing and lightweight analytics.

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

You access webhook payload data in an n8n Code node by referencing the _json object. Specifically, extract the incoming webhook payload by accessing the body attribute via _json["body"] for processing.

What is the required output format for Python scripts in n8n Code nodes?

The required output format for Python scripts in n8n Code nodes is an array containing item objects. Each item object must have a json key holding the transformed data, ensuring proper downstream workflow execution.

Does n8n support Python regex extraction and aggregation in Code nodes?

Yes, n8n supports Python regex extraction and aggregation in Code nodes. By importing standard library modules like re and statistics, you can perform pattern matching, data filtering, and aggregation directly within your workflow.

Why does my Python Code node in n8n fail when processing multiple items?

Your Python Code node in n8n may fail if you do not use the correct data access methods for the mode. Use _input.all() for All Items mode or _input.item for Each Item mode, and always return the mandated array format.