Printing with Python based Code node

Describe the problem/error/question

When I use the Python code node, and try to print to the browser console using print function, I can’t figure out how to print objects. I think Pyodide returns a JS object, so all I get is:

[object Object]

How can I get the object printed?

What is the error message (if any)?

N/A

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: Cloud
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n Cloud
  • Operating system: N/A

Hey @hawkar hope all is well and welcome to the community.

See if this example helps with printing from the python script

If this doesn’t help, please provide your example / exact use case.

Hi, yes that works because your printing scalar values, but when you print a Python dict (an object in JS) it doesn’t work. In JS you’d use JSON.stringify() to convert the object to a string and make it visible in the console. But in this case we have JSON → Python → JS Object.

My data looks like this:

If I try to print the individual values it works, but printing an object, like each model in the screenshot above produces [object Object] in the console.

See if this helps then

This doc is just about that.

I can help you resolve this. The [object Object] output usually happens due to how Pyodide handles Python objects in the browser. I’ll set up the Python code node properly so your objects are printed in a readable format using the right serialization method.

I’ll make sure you get clear, structured output in the console. Looking forward to fixing this for you!
:date: Book a call
:link: Upwork Profile

1 Like