Easy Tech Tuts
n8n

How to Run and Automate Python Scripts With n8n Easily 2026

By Impran M N

n8n's Code node isn't limited to JavaScript; it can also run Python, giving you access to a more familiar syntax for certain data processing tasks. This guide covers switching the node to Python mode, working with incoming data, and returning structured output for the rest of your workflow.

01Add the Code node

Place the Code node onto your workflow canvas where you want to run custom logic.

02Switch to Python mode

Use the language selection option inside the node settings to change from JavaScript to Python.

03Access incoming data

Reference data from previous nodes, which becomes available as structured input inside your script.

04Write and structure your script

Process the data with your Python logic, cleaning or transforming it as needed.

05Return output and test

Return your results in the expected list format, then run a test to confirm downstream nodes receive it correctly.

FAQ

Frequently asked questions

Can I run Python instead of JavaScript in n8n?

Yes, the Code node includes a language toggle that lets you switch from JavaScript to Python.

How do I access data from earlier nodes inside a Python script?

Incoming data is made available inside the Code node, which you can reference directly in your script.

Can I use external Python libraries in n8n's Code node?

Support for external packages depends on your n8n environment configuration, so check what's available in your setup.

What format should my Python script return data in?

Output should be structured as a list so downstream nodes can process it correctly.

Watch the full walkthrough

The same steps, demonstrated on screen from start to finish.