Skip to content

Python Code

The Python Code node allows you to write and execute Python scripts directly within your workflow. Unlike traditional automation tools that require a server, this node runs entirely inside your browser using Pyodide.

This is perfect for cleaning data, performing calculations, or using advanced math libraries without your data ever leaving your computer.

Illustration of Python code running in a browser environment

The node receives data from the previous step as a list of items. You can modify these items, create new ones, or filter them out using standard Python syntax. Because it uses Pyodide, you have access to the standard Python library and several powerful scientific packages.

graph LR
  A --> B{Python Code Node}
  B --> C
  style B fill:#ffd43b,stroke:#333,stroke-width:2px
  1. Add the node: Locate the Python Code node under the “Core” category and add it to your workflow canvas.
  2. Write your script: Enter your Python code in the editor. By default, the node provides a template to help you get started.
  3. Access data: Use the built-in items variable to interact with the data flowing into the node.
  4. Return results: Your script must return a list of dictionaries (objects) so the next node can understand the data.

If you want to add a new field to every item passing through, you can use a simple loop.

transform.py
# 'items' is the list of data coming from the previous step
new_items = []
for item in items:
# Add a new field called 'status'
item['status'] = 'processed'
# Calculate a new total price
item['grand_total'] = item['price'] * 1.2
# Add the updated item to our list
new_items.append(item)
# Always return the modified list
return new_items

One of the biggest advantages of the Python Code node is the support for heavy-duty data libraries. These are pre-loaded and ready to use:

LibraryBest for
PandasComplex table manipulation and data analysis.
NumPyHigh-performance mathematical operations.
MatplotlibGenerating charts and visualizations.

You can easily remove items that don’t meet a specific condition.

# Only keep items where the price is greater than 50
return [item for item in items if item['price'] > 50]

Clean up names or labels before sending them to a database.

for item in items:
item['name'] = item['name'].strip().title()
return items
  • Browser Only: This code executes on your machine. If you share a workflow, the recipient’s browser will run the code when they trigger it.
  • External Requests: Standard Python requests are not supported. Use our(/nodes/builtin/browser/click/) or(/nodes/builtin/core/http/) to fetch data from the web.