Structured Output Helper
Build a strict structured-output contract from a sample JSON value, or repair fenced/trailing-comma JSON into valid JSON — locally.
- Runs locally in your browser
- No upload required
Try it
Supported formats
Privacy
Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.
Repaired the value to valid JSON.
How it works
- Parsed the provided value (repairing a Markdown fence, trailing commas or single-quoted strings first).
- Re-parsed the repaired text to confirm it is valid JSON.
- Removed the surrounding Markdown code fence.
- Removed trailing comma(s) before } or ].
Methodology
- Strip a surrounding Markdown code fence, remove trailing commas before `}`/`]`, and convert single-quoted strings when no double quotes exist.
- Re-parse the repaired text as JSON; an irreparable value is reported, never thrown.
- In contract mode, walk the parsed value to list each field path and type and emit a strict output instruction.
Usage
- Paste a sample JSON value or a model's JSON reply.
- Choose Repair to fix common faults, or Contract to describe the output shape.
- Copy the repaired JSON or the contract instruction.
Examples
These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.
Repair a fenced reply
{
"value": "```json\n{\"ok\":true,}\n```",
"mode": "repair"
}Describe an output contract
{
"value": "{\"id\":1,\"name\":\"seo\",\"tags\":[\"a\",\"b\"]}",
"mode": "contract"
}Limitations
Model JSON is often almost valid
Models frequently wrap JSON in a fence or leave a trailing comma. Repairing first lets you validate or diff the output without editing it by hand.
Frequently asked questions
- Does the repair send my data anywhere?
- No. All parsing and repair happen in your browser; nothing is transmitted.
- Can it validate against a schema?
- No. Use the JSON Schema Validator for validation; this tool repairs JSON and describes an output shape.
Sources
Send feedback
Tell us if this tool helped, report a problem, or suggest a tool. Only the message you type is sent — never the input you used in the tool.
Was this tool useful?
Prefer to write to us directly? See the contact page.