What problem does it solve?
Python in n8n Code nodes is constrained to the standard library and requires careful data access patterns and return formats. This guide helps you understand how to write reliable Python code inside n8n Code nodes within the no-external-libraries constraint.
Core Features & Use Cases
- Clear data access patterns for _input.all(), _input.first(), and _input.item, plus safe handling of webhook data under ["body"].
- Standard-library-first guidance for common tasks (json, datetime, re, base64, hashlib, urllib.parse) and defensive programming to avoid KeyError and IndexError.
- Practical patterns and examples for data transformation, validation, aggregation, and secure integration with n8n nodes.
- Quick-start approach to implement a simple Python Code node that reads from input, processes, and returns a properly formatted json-wrapped output.
Quick Start
Write a small Python Code node that reads all items via _input.all(), applies a transformation on each item, and returns a list of {"json": ...} objects.