n8n-code-python

Write and execute Python scripts in n8n Code nodes.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/pessini/aria --skill n8n-code-python-pessini
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/pessini/aria/tree/main/backend/agents/n8n_agent/skills/n8n-code-python
Command: npx skills add https://github.com/pessini/aria --skill n8n-code-python-pessini

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guidance and patterns for writing Python code within n8n Code nodes, enabling data transformation and automation tasks directly within your workflows.

Core Features & Use Cases

  • Python Code Execution: Write and execute Python scripts within n8n.
  • Data Access Patterns: Learn how to access input data using _input.all(), _input.first(), and _input.item.
  • Error Prevention: Avoid common pitfalls like ModuleNotFoundError, KeyError, and incorrect return formats.
  • Use Case: Transform incoming webhook data, aggregate data from multiple sources, or perform complex calculations that are more easily expressed in Python.

Quick Start

Use the n8n-code-python skill to write a Python script that processes all incoming items and returns them with an added 'processed' field.

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 workflows?

To write Python code in n8n workflows, use the Code node and execute scripts for data transformation. Access input data using patterns like `_input.all()` or `_input.first()`, and return the processed items to pass them downstream.

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

Access input data in an n8n Python Code node using `_input.all()` for all items, `_input.first()` for the initial item, or `_input.item` for the current item. These patterns allow you to manipulate incoming webhook data or aggregate multiple sources effectively.

Why does my Python script in n8n throw a ModuleNotFoundError?

A Python script in n8n throws a ModuleNotFoundError when importing unavailable libraries. To avoid this error, rely on standard Python libraries available within the n8n environment and follow error prevention best practices for your data manipulation tasks.

Can I use Python to transform webhook data in n8n?

Yes, you can use Python to transform webhook data in n8n. By writing scripts within the Code node, you can process incoming webhook payloads, perform complex calculations, aggregate data from multiple sources, and add fields like 'processed' before returning the items.

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

The correct return format for Python scripts in n8n requires returning a list of dictionaries representing the output items. Avoiding incorrect return formats is a key error prevention practice to ensure your workflow continues passing data downstream without KeyErrors.