# Problems generating valid json from mongoDB component to my Database

**URL:** <https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605>\
**Category:** Questions\
**Created:** [December 20, 2025, 3:25am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605 "2025-12-20T03:25:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliascanaza](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/eliascanaza/32/141220_2.png) [@eliascanaza](https://community.n8n.io/u/eliascanaza)\
**Post date:** [December 20, 2025, 3:25am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/1 "2025-12-20T03:25:20Z")

</div>

Hi guys, I am strougling with AI agent and Mongo DB component, I want to insert the data from my google sheet component into database also, but seems I am doing something wrong, I pasted the instruction from my AI agent and the output in MongoDB component but I am getting a wrong format into database, do you know a way to generate a VALIDA JSON for my mongo db? here the screenshots

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/3/03609f0482850e242c32d2d227a4443016975d85.png)

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

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

---

<div class="post-metadata">

**Author:** ![Soban\_Kasmani](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/soban_kasmani/32/146410_2.png) [@Soban\_Kasmani](https://community.n8n.io/u/Soban_Kasmani)\
**Post date:** [December 20, 2025, 6:17am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/2 "2025-12-20T06:17:28Z")

</div>

Hi, Can you share whole mongodb node of n8n and json of mongodb node.

---

<div class="post-metadata">

**Author:** ![eliascanaza](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/eliascanaza/32/141220_2.png) [@eliascanaza](https://community.n8n.io/u/eliascanaza)\
**Post date:** [December 20, 2025, 1:17pm UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/3 "2025-12-20T13:17:50Z")

</div>

This is the LLM description:

Get last row from Google Sheet component and generate a valid JSON format to insert into mongo db, consider these keys:

Phone Number,  
Store,  
Category,  
Address,  
Expense Description,  
Expense Amount,  
Registered Date

This is my JSON format I want to generate to insert into Mongo db:

{  
“Phone Number”: “1111111”,  
“Expense Date”: “2025-12-12”,  
“Store”: “mcdonald”,  
“Category”: “food”,  
“Address”: “aa 221 north”,  
“Expense Description”: “my stuffs”,  
“Expense Amount”: “212.6”,  
“Registered Date”: “441234123”  
}

---

<div class="post-metadata">

**Author:** ![Soban\_Kasmani](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/soban_kasmani/32/146410_2.png) [@Soban\_Kasmani](https://community.n8n.io/u/Soban_Kasmani)\
**Post date:** [December 21, 2025, 7:28am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/4 "2025-12-21T07:28:34Z")

</div>

Currently, you are facing an error because the LLM is not providing a valid output.

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/1/411b7c1236ab12a4620b23b14dfcc2731e87884d.jpeg)

Change the prompt and try this one.  
{  
“Phone Number”: “{{ $fromAI(‘phone\_number’, `This is the phone number`, ‘string’) }}”,  
“Expense Date”: “{{ $fromAI(‘expense\_date’, `This is the expense date`, ‘string’) }}”,  
“Store”: “{{ $fromAI(‘store’, `This is the store`, ‘string’) }}”,  
“Category”: “{{ $fromAI(‘category’, `This is the category`, ‘string’) }}”,  
“Address”: “{{ $fromAI(‘address’, `This is the address`, ‘string’) }}”,  
“Expense Description”: “{{ $fromAI(‘expense\_desc’, `This is the expense desc`, ‘string’) }}”,  
“Expense Amount”: “{{ $fromAI(‘expense\_amount’, `This is the expense amount`, ‘string’) }}”,  
“Registered Date”: “{{ $fromAI(‘registered\_date’, `This is the registered date`, ‘string’) }}”,  
}

---

<div class="post-metadata">

**Author:** ![eliascanaza](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/eliascanaza/32/141220_2.png) [@eliascanaza](https://community.n8n.io/u/eliascanaza)\
**Post date:** [December 21, 2025, 2:12pm UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/5 "2025-12-21T14:12:49Z")

</div>

> [@Soban\_Kasmani](#):
>
> “Phone Number”: “{{ $fromAI(‘phone\_number’, `This is the phone number`, ‘string’) }}”,  
> “Expense Date”: “{{ $fromAI(‘expense\_date’, `This is the expense date`, ‘string’) }}”,  
> “Store”: “{{ $fromAI(‘store’, `This is the store`, ‘string’) }}”,  
> “Category”: “{{ $fromAI(‘category’, `This is the category`, ‘string’) }}”,  
> “Address”: “{{ $fromAI(‘address’, `This is the address`, ‘string’) }}”,  
> “Expense Description”: “{{ $fromAI(‘expense\_desc’, `This is the expense desc`, ‘string’) }}”,  
> “Expense Amount”: “{{ $fromAI(‘expense\_amount’, `This is the expense amount`, ‘string’) }}”,  
> “Registered Date”: “{{ $fromAI(‘registered\_date’, `This is the registered date`, ‘string’) }}”,  
> }

I tryed but same result:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/c/5/c571092ffe87f2a381ec1d12798442a3cdcf064d.png)

---

<div class="post-metadata">

**Author:** ![Parintele\_Damaskin](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/parintele_damaskin/32/139243_2.png) [@Parintele\_Damaskin](https://community.n8n.io/u/Parintele_Damaskin)\
**Post date:** [December 21, 2025, 6:03pm UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/6 "2025-12-21T18:03:41Z")

</div>

Hey @eliascanaza !

I think you have to switch from “Tool Description “ to manually and enter like this :

Insert an object in database. Send with the different json just with the values of the

{{ $fromAI(‘full\_name’, `Name of the customer`, ‘string’) }},

{{ $fromAI(‘contact’, `Customer’s contact`, ‘string’) }},

{{ $fromAI(‘description’, `Appointment description`, ‘string’) }},

{{ $fromAI(‘start\_appointment\_time’, `Start time of the appointment (ISO datetime)`, ‘string’) }},

{{ $fromAI(‘end\_appointment\_time’, `End time of the appointment (ISO datetime)`, ‘string’) }}

**The last parameter doesn’t have comma , 'sign.**

Better check this post , is quite the same “issue”.

> [@Ai Agent parsing issue with mongodb tool](http://community.n8n.io/t/ai-agent-parsing-issue-with-mongodb-tool/192004/6):
>
> Finally I got the solution. The tool description should be Insert an object in database. Send with the different json just with the values of the {{ $fromAI('full\_name', `Name of the customer`, 'string') }}, {{ $fromAI('contact', `Customer's contact`, 'string') }}, {{ $fromAI('description', `Appointment description`, 'string') }}, {{ $fromAI('start\_appointment\_time', `Start time of the appointment (ISO datetime)`, 'string') }}, {{ $fromAI('end\_appointment\_time', `End time of the appointment …

Hope this helps!

Cheers!

---

<div class="post-metadata">

**Author:** ![eliascanaza](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/eliascanaza/32/141220_2.png) [@eliascanaza](https://community.n8n.io/u/eliascanaza)\
**Post date:** [December 21, 2025, 11:41pm UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/7 "2025-12-21T23:41:13Z")

</div>

I have tried many ways but still with issues:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/8/f/8f094ea69fdd6f4efaa42a5ce742f06439af6891.png)

---

<div class="post-metadata">

**Author:** ![Parintele\_Damaskin](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/parintele_damaskin/32/139243_2.png) [@Parintele\_Damaskin](https://community.n8n.io/u/Parintele_Damaskin)\
**Post date:** [December 22, 2025, 7:46am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/8 "2025-12-22T07:46:59Z")

</div>

You are doing it WRONG… check the post I shared, or at last how I said to put the parameters in description. As far I can see you put : “

Phone Number”: “{{ $fromAI(‘phone\_number’, `This is the phone number`, ‘string’) }}”,

Instead do:

Insert an object in database. Send with the different json just with the values of the

{{ $fromAI(‘phone\_number’, `phone number customer`, ‘string’) }},

ETC…

---

<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:** [March 22, 2026, 7:47am UTC](https://community.n8n.io/t/problems-generating-valid-json-from-mongodb-component-to-my-database/238605/9 "2026-03-22T07:47:13Z")

</div>

Closed on March 22, 2026, 7:47am UTC

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