How to Fix JSON From AI

AI tools are good at producing JSON-shaped text. They are less reliable at producing strict JSON every time.

Start With Structure

Valid JSON needs double-quoted keys and strings, no trailing commas, lowercase booleans, and balanced braces. If any of those are wrong, parsers fail before your workflow even reaches the useful part.

Common Breaks

The most common AI mistakes are markdown code fences, intro text, unquoted keys, single quotes, Python values like True or None, and arrays with a final comma.

Repair, Then Validate

A repair tool can make the JSON parse. That does not mean the content is correct. After repair, check names, IDs, links, numbers, dates, and any claim that matters.

Use a Better Prompt Next Time

Ask the model for "strict JSON only, no markdown, no explanation." If the output feeds a program, include a schema or a compact example.