What problem does it solve?
Python can be used inside n8n Code nodes, but is constrained to the standard library and relies on explicit data access patterns. This skill provides guidance on writing Python in n8n Code nodes, safely accessing data via _input/_json/_node, and returning data in the required format.
Core Features & Use Cases
- Official data access patterns: _input.all(), _input.first(), _input.item, and _node references.
- No external libraries: standard library only (json, datetime, re, etc.) and how to work within that limitation.
- Webhook gotcha: data from webhooks is nested under body.
- Return format: always return a list of objects with a top-level json key.
- Common patterns: safe dictionary access with .get(), handling empty lists, and error prevention.
- Use Case: Transform a batch of items, validate per-item data, or compute simple statistics using Python's standard library.
Quick Start
Use this template to start coding:
items = _input.all()
processed = []
for item in items:
processed.append({"json": {**item["json"], "processed": True}})
return processed