Json issue with openAi send a message node

Hello everyone, I’m working one a small static website scrapper to begin n8n (content, links, resume), but it turns ou I got issues when messaging a model here’s the problem :

The ai response gives me a string with the json inside. So for the moment I added a javascript node to keep only the string and to tun it into json. Is there any other way the ai node can return the json itself ?

hello @nmcmill

Use options > Output Format > JSON Schema and specify a JSON schema. Otherwise, it may output garbage JSON or even something that looks like JSON, but is not the JSON.

+1 to the JSON Schema approach, that’s the cleanest way. one extra tip — if you’re on the Basic LLM Chain instead of the OpenAI node, you can also add a Structured Output Parser subnode, it handles the schema enforcement automatically without touching Options.