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

Valid JSON
Yes
Findings
Removed the surrounding Markdown code fence. · Removed trailing comma(s) before } or ].
{"ok":true}

Supported formats

Input
application/json, text/plain
Output
application/json, text/plain

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

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

  1. Strip a surrounding Markdown code fence, remove trailing commas before `}`/`]`, and convert single-quoted strings when no double quotes exist.
  2. Re-parse the repaired text as JSON; an irreparable value is reported, never thrown.
  3. In contract mode, walk the parsed value to list each field path and type and emit a strict output instruction.

Usage

  1. Paste a sample JSON value or a model's JSON reply.
  2. Choose Repair to fix common faults, or Contract to describe the output shape.
  3. 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

jsonSelect to copy
{
  "value": "```json\n{\"ok\":true,}\n```",
  "mode": "repair"
}

Describe an output contract

jsonSelect to copy
{
  "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

  1. JSON Schema 2020-12 specification — JSON Schema
  2. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format — IETF