# How to Parse OPENAI node response

**URL:** <https://community.n8n.io/t/how-to-parse-openai-node-response/22280>\
**Category:** Questions\
**Tags:** openai\
**Created:** [January 26, 2023, 10:21am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280 "2023-01-26T10:21:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nvenhuizen14](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nvenhuizen14/32/21676_2.png) [@nvenhuizen14](https://community.n8n.io/u/nvenhuizen14)\
**Post date:** [January 26, 2023, 10:21am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/1 "2023-01-26T10:21:40Z")

</div>

How to parse the repsonse from OpenAI node. I am currently using openAI to classify Bank transactions into Category, Group, and Keyword.. I have it set to return a JSON but the returned json is not formatted correctly. I haven’t been able to figure out how to use json or jmespath to correctly parse the data, so i guess my real question is how to use json or jmespath to parse this openai data:

 ![Screenshot_20230126_051814](https://europe1.discourse-cdn.com/n8n/original/3X/4/8/481bc3ee71df6f9658470d3522a4cbc05410ba9d.png)  
 ![Screenshot_20230126_051822](https://europe1.discourse-cdn.com/n8n/original/3X/9/a/9af7629bda4e9d77823081daac871879371807ee.png)

I’m open to any other solution as well, as this part of the workflow is CRUICAL to my project! MUCH thanks in advanced for anyone who spend even a second helping me learn!

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [January 26, 2023, 10:29am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/2 "2023-01-26T10:29:33Z")

</div>

Hey @nvenhuizen14,

Try using `{{ JSON.parse($json.text) }}` in a set node, This will return something like this…

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/7/7/774d18cc3c4a9486ece9cae677d2cbb28609e4a3.png)

Example workflow to produce some Pineapple based JSON…

---

<div class="post-metadata">

**Author:** ![nvenhuizen14](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nvenhuizen14/32/21676_2.png) [@nvenhuizen14](https://community.n8n.io/u/nvenhuizen14)\
**Post date:** [January 26, 2023, 10:37am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/3 "2023-01-26T10:37:50Z")

</div>

Thank you for responding!

unfortunately with {{ JSON.parse($json.text) }} i receive undefined 😕

 ![Screenshot_20230126_053622](https://europe1.discourse-cdn.com/n8n/original/3X/6/d/6dac13ee92343a6cd6abcfd9cd4f956b1e94ec74.png)

---

<div class="post-metadata">

**Author:** ![BramKn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bramkn/32/11894_2.png) [@BramKn](https://community.n8n.io/u/BramKn)\
**Post date:** [January 26, 2023, 10:52am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/4 "2023-01-26T10:52:21Z")

</div>

Is this the same topic as this?

> [@Help with JSON.parse](http://community.n8n.io/t/help-with-json-parse/22242):
>
> Can anyone help me? i just cant figure this one out i’ve been stuck forever now. You have no idea how much i’d appreciate it!

---

<div class="post-metadata">

**Author:** ![nvenhuizen14](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nvenhuizen14/32/21676_2.png) [@nvenhuizen14](https://community.n8n.io/u/nvenhuizen14)\
**Post date:** [January 26, 2023, 10:53am UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/5 "2023-01-26T10:53:27Z")

</div>

yes i apologise. I did not explain my situation well in the last one and couldnt figure out how to delete it

---

<div class="post-metadata">

**Author:** ![Niklas\_Hatje](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/niklas_hatje/32/155398_2.png) [@Niklas\_Hatje](https://community.n8n.io/u/Niklas_Hatje)\
**Post date:** [January 26, 2023, 12:43pm UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/6 "2023-01-26T12:43:08Z")

</div>

Hey @nvenhuizen14, it seems like your openAI node is not returning correct JSON as it’s missing the outer {}. Try something like this:

---

<div class="post-metadata">

**Author:** ![nvenhuizen14](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nvenhuizen14/32/21676_2.png) [@nvenhuizen14](https://community.n8n.io/u/nvenhuizen14)\
**Post date:** [January 26, 2023, 7:13pm UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/7 "2023-01-26T19:13:55Z")

</div>

YUP THAT DID IT! thank you man! that’s been driving me crazy! lol

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [February 2, 2023, 7:14pm UTC](https://community.n8n.io/t/how-to-parse-openai-node-response/22280/8 "2023-02-02T19:14:27Z")

</div>

Closed on February 2, 2023, 7:14pm UTC

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