n8n-code-python

Write Python code in n8n Code nodes using standard library and data access patterns.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/Sebasarmas19/Chatbot-Reminder --skill n8n-code-python-sebasarmas19
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-python
Source: https://github.com/Sebasarmas19/Chatbot-Reminder/tree/main/n8n-skills/skills/n8n-code-python
Command: npx skills add https://github.com/Sebasarmas19/Chatbot-Reminder --skill n8n-code-python-sebasarmas19

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Python in n8n Code nodes fails frequently because of undocumented constraints: no external libraries, webhook data nested under body, strict return format requirements, and confusing data access syntax. This Skill provides the patterns and error prevention guidance needed to write working Python Code nodes on the first attempt. ## Core Features & Use Cases - Data Access Patterns: Complete guidance on _input.all(), _input.first(), _input.item, and _node references, including the critical webhook body nesting gotcha. - Standard Library Reference: Documents which Python modules are available (json, datetime, re, base64, hashlib, urllib.parse, statistics) and workarounds for missing libraries like requests and pandas. - Error Prevention: Covers the top 5 Python Code node errors (ModuleNotFoundError, missing return, KeyError, IndexError, incorrect return format) with fixes. - Use Case: You receive webhook data in n8n and need to filter, transform, and aggregate it in Python. The Skill shows you to access data via _input.first()["json"]["body"], use .get() for safe dictionary access, and return results as [{"json": {...}}]. ## Quick Start Ask the AI to write a Python Code node that filters active items from the previous node and returns them with a processed timestamp.

Frequently Asked Questions about n8n-code-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I access webhook data in an n8n Python Code node?

Access webhook data via _input.first()["json"]["body"], because the Webhook node nests all payload data under the body property. Use .get() chaining like _json.get("body", {}).get("name") to avoid KeyError on missing fields.

Can I use requests or pandas in n8n Python Code nodes?

No, n8n Python Code nodes only support the standard library, so requests, pandas, and numpy raise ModuleNotFoundError. Use the HTTP Request node for API calls or switch to JavaScript, which offers $helpers.httpRequest.

What is the correct return format for n8n Code nodes?

Code nodes must return a list of dictionaries where each item has a json key, like return [{"json": {"result": "success"}}]. Returning a plain dictionary, string, or None causes workflow execution failures.

Should I use Python or JavaScript in n8n Code nodes?

JavaScript is recommended for about 95% of use cases because it includes n8n helpers and the Luxon date library. Use Python only when you need standard library modules like statistics, re, or hashlib, or prefer Python syntax.

Why does my n8n Python Code node throw KeyError or IndexError?

KeyError occurs from direct dictionary access on missing keys, and IndexError from indexing empty lists. Fix both by using .get() with defaults for dictionaries and checking len(items) or using slicing before list access.