FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Stop JSON.parse From Crashing on LLM Responses
How-ToWeb Development

Stop JSON.parse From Crashing on LLM Responses

via Dev.to JavaScriptAaron Decker2h ago

I want to show you every way an LLM can break your JSON.parse call, and how to handle all of them in one line. The many ways LLMs break JSON If you're calling OpenAI, Claude, Gemini, Ollama, or any other LLM and asking for JSON, here's what you'll eventually get back: 1. Markdown code fences The most common one. You ask for JSON, the model gives you a helpful little markdown block: Sure! Here you go: ​``` { % endraw % } json { "score" : 95 } ​ { % raw % } **2. Trailing commas** Models love trailing commas. Especially in arrays. ```json {"items": ["a", "b", "c",], "count": 3,} 3. Unquoted keys The model writes JavaScript instead of JSON: { name: "Alice" , age: 30 , active: true } 4. Single quotes { 'name': 'Alice' , 'city': 'New York' } 5. Smart quotes and em dashes Copy-paste artifacts or just models being fancy: { "name" : "Alice" , "range" : "10—20" } Those " and — characters look right but they are not ASCII and JSON.parse will reject them. 6. Inline comments { "name" : "Alice" , //

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
0 views

Related Articles

I Haven’t Written Real Code in 3 Months. My Products Still Ship.
How-To

I Haven’t Written Real Code in 3 Months. My Products Still Ship.

Medium Programming • 1h ago

My Learning Experience with Sorting Algorithms
How-To

My Learning Experience with Sorting Algorithms

Dev.to Tutorial • 3h ago

Stop Building Projects. Start Building Systems.
How-To

Stop Building Projects. Start Building Systems.

Medium Programming • 3h ago

I Learned More in 3 Months Than 3 Years (The System That Actually Works)
How-To

I Learned More in 3 Months Than 3 Years (The System That Actually Works)

Medium Programming • 4h ago

CA 12 - Next Permutation
How-To

CA 12 - Next Permutation

Dev.to • 4h ago

Discover More Articles