# Convert python output from string to array

**URL:** <https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837>\
**Category:** General\
**Created:** [23 January 2024 17:00 UTC](https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837 "2024-01-23T17:00:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [23 January 2024 17:00 UTC](https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837/1 "2024-01-23T17:00:58Z")

</div>

I have a python exec which outputs a list (2D array) but in Node Red it becomes a string:

 ![Screenshot 2024-01-23 alle 18.00.20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/55dd460ffc5ef420ad11834204f464024f04bd26.png)

How can I get the array in NR?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 January 2024 17:04 UTC](https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837/2 "2024-01-23T17:04:33Z")

</div>

If the python is simple, re-do it with node-red flows/nodes - thats the best solution IMO.

If you can fix the python to output valid JSON, thats the 2nd best solution.

Failing that, regex + string replacements (good luck)

* * *

PS, as always, if you post text data instead of images, someone will likely pop in and show you how.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [23 January 2024 17:05 UTC](https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837/3 "2024-01-23T17:05:32Z")

</div>

> [@Steve-Mcl](#):
>
> If you can fix the python to output valid JSON, thats the 2nd best solution.

I will go this way. thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 February 2024 17:05 UTC](https://discourse.nodered.org/t/convert-python-output-from-string-to-array/84837/4 "2024-02-06T17:05:58Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
