Clean up JSON from LLMs
Take messy output from a model, validate it to find where it broke, format it, then generate a JSON Schema to lock the shape down for future generations.
1,000 free AI credits on signup · Core tools run locally
How to clean up JSON from a model
- 1
Paste the model output
Drop the raw response into the editor, including any wrapper text the model added around the JSON. The core tools run in your browser, so the payload stays on your machine.
- 2
Validate to find the break
Run validation to catch trailing commas, unquoted keys, single quotes, and truncated output. You get the line and column where parsing failed instead of a vague "unexpected token".
- 3
Format it
Once the JSON parses, format it with one click to get consistent indentation and sorted keys. Now you can read the shape and confirm the model returned what you asked for.
- 4
Generate a schema to constrain future output
Generate a JSON Schema from the cleaned sample. Reuse it in your pipeline to reject any future generation that drifts from the expected shape.
What you get
Line-level validation
Errors point to the exact line and column, so you find the trailing comma or missing quote without scanning the whole blob.
Catches common model mistakes
Unquoted keys, single quotes, trailing text after the closing brace, and truncated objects all show up as specific parse errors.
One-click format
Turn a single line into readable, indented JSON. Core formatting runs locally and never uploads your data.
Schema generation from a sample
Generate a JSON Schema from one clean response, then validate later generations against it to catch shape drift early.
Schema plus AI descriptions
Generate a schema with field descriptions when you want documentation for the structure the model returns. This AI action uses credits.
Local core processing
Format, minify, validate, and tree view run entirely in the browser. JSON only leaves your machine when you choose to run an AI action.
Frequently asked questions
Why does LLM JSON break so often?
Models generate text token by token, so they can emit a trailing comma, drop a closing brace, use single quotes, or wrap the JSON in an explanation. Long responses also get truncated when they hit a token limit, leaving an object half-finished.
Why does ChatGPT return invalid JSON?
ChatGPT wraps output in markdown code fences, adds explanatory prose before or after the object, uses single quotes instead of double quotes, and cuts off long responses at the token limit — any one of these breaks JSON.parse. Paste the response into the JSON Repair tool at /json-repair to strip the fences and prose, fix the quotes, and close truncated brackets in one click.
Can it fix the JSON automatically?
Validation and formatting handle structural problems: validate finds where parsing fails and format cleans up indentation once it parses. For deeper repair or restructuring, the AI Copilot actions like Explain and Flatten help you understand and reshape the data. For trailing prose and other artifacts around valid JSON, the JSON Repair tool at /json-repair strips them automatically.
How do I stop bad output in future?
Generate a JSON Schema from one good response, then validate each new generation against that schema in your pipeline. Anything that drifts from the expected shape gets rejected before it reaches your code.
Is it free?
Validating, formatting, minifying, and the tree view are free and run locally. The AI Copilot actions use credits based on the input and output size, so you only pay for what each run uses. New accounts get 1,000 free credits to start.