Python in the n8n Code-Node: Possibilities and Limits
Python runs in the n8n Code-Node via Pyodide or native execution, with clear limitations on external packages. A practical overview.
The Code-Node in n8n can be fed with either JavaScript or Python, but with noticeable differences: JavaScript runs natively, Python goes through an additional compilation step and is thus slower, and the availability of external Python packages depends heavily on whether n8n is self-hosted or running in the cloud. Status: August 2026.
What Python runtimes does n8n offer?
According to n8n official documentation offers two different ways to run Python in the Code-Node. The original variant uses Pyodide, a port of CPython to WebAssembly, which significantly restricts available packages. Since version 1.111.0, n8n additionally supports native Python execution via its own task runners, which is considered stable from n8n version 2 onwards. Which variant is actually active depends on the configuration of the instance. An overview of both programming options in the tool is provided by the Getting started with Code in n8n.
Which packages can be used in practice?
The biggest limitation lies here, and it differs significantly depending on the mode of operation:
- n8n Cloud: In neither Pyodide nor native Python mode can external libraries be imported.
- Self-Hosted with native Python: External modules are possible if the runner image used contains them and they are explicitly approved.
- Self-Hosted with Pyodide: Package selection is limited by the WebAssembly environment from the outset, regardless of your own configuration.
The n8n community regularly sees similar reports: requests to install packages directly, error messages about disallowed external packages, and notices that Python needs to be installed afterwards in lean Docker images like Alpine-based containers. Anyone wanting to work productively with Python packages in self-hosting rarely gets around needing their own customized Docker image.
Why is Python mode slower than JavaScript?
According to n8n documentation, processing Python code fundamentally takes longer than JavaScript because additional compilation steps are required before the actual code is executed. For individual nodes running occasionally, this rarely makes a difference. With workflows running at high frequency or processing large amounts of data in the Code-Node, however, the difference can noticeably affect overall runtime, which should be a consideration when choosing between JavaScript and Python once performance matters.
When is a different node the better choice?
Not every task belongs in the Code-Node, even if it could technically be solved there. For file system access, the documentation recommends the Read/Write File From Disk Node, for HTTP requests the HTTP Request Node, rather than rebuilding these functions in your own Python or JavaScript code. This has two advantages: the dedicated nodes are optimized for n8n workflows and come with their own error handling, and the workflow remains readable for colleagues without programming knowledge. The Code-Node is best suited for transformation logic that cannot be represented with the standard nodes or only with difficulty.
Is Python worthwhile compared to JavaScript?
For most automations in n8n, JavaScript is the more pragmatic choice, simply because of speed and native support. Python becomes particularly interesting when a team already has Python knowledge or when existing data processing logic from a Python script needs to be incorporated. For more complex automation projects, such as in combination with AI Agents, it is worth taking a closer look at the package availability of your own instance beforehand, so that the planned logic will actually be executable later.
Frequently asked questions about Python in the n8n Code-Node
Can I install any Python packages in n8n Cloud?
No, in n8n Cloud, external libraries cannot be imported in either Pyodide or native Python mode. Anyone relying on specific packages needs a self-hosted instance with a properly configured runner image.
What is the difference between Pyodide and native Python?
Pyodide is a port of CPython to WebAssembly with restricted package availability, while the native Python execution available since version 1.111.0 runs via task runners and offers more flexibility with external modules in self-hosting.
Is Python in the Code-Node as fast as JavaScript?
No, according to documentation, processing Python code takes longer than JavaScript because additional compilation steps are required. For individual nodes it rarely matters, but with high execution frequency it can noticeably affect runtime.
Should I program file access and HTTP requests in the Code-Node?
Better not: n8n recommends using the Read/Write File From Disk Node or the HTTP Request Node instead. This keeps the workflow maintainable and uses the built-in error handling of these nodes instead of your own code.
Simon Glowik
Founder of NordFlux. Spent four years automating processes at enterprise scale at Dräger, and now brings that depth to the mid-market — pragmatic and with full data sovereignty.
Certifications
- Microsoft certified — PL-900 and AZ-900
- UiPath certified — Automation Developer Associate
- UiPath zertifiziert — Automation Developer Associate
Concrete questions about automation or AI?
In a free initial analysis we discuss your case directly. No strings attached.