Skip to content
DevTinyTools

JSON Repair

Fix the small things that make a JSON document fail: a code fence, a trailing comma, a Python boolean, single quotes, a comment, or a cut-off tail. You see every change, and the result must pass a strict parse before it is shown.

Runs entirely in your browser — your JSON is never uploaded.

Everything runs in this browser tab. Nothing is uploaded.

0 chars

A worked example

Repair only applies mechanical rewrites. Every change is reported, so you can see what the tool decided.

Input

```json
{
  name: "Ada",
  active: True,
}
```

Output

{
  "name": "Ada",
  "active": true
}

Changes:
- removed markdown fence
- quoted bare key: name
- quoted bare key: active
- True -> true
- removed trailing comma

A strict JSON.parse must accept the result before the repaired document is shown.

How to repair a document

  • Paste the broken text, including any code fence or chatty text around it. The tool extracts the document first.
  • Press Repair JSON. Each rewrite is recorded below the button.
  • Copy the repaired text, or press Use as input to run another pass — for example to validate it afterwards.

If the pasted text is already valid, nothing is rewritten. A repair that cannot reach a strict parse is never shown as a result, so you will not be handed text that still fails downstream.

What it fixes, and what it does not

Broken JSON symptoms and the repair applied to each
You pastedRepair appliedWhy it matters
```json … ``` around the outputFence removedCommon when copying an answer from a chat assistant.
Text before or after the documentSurrounding prose removedOnly text outside the outermost braces or brackets is removed.
// comment or /* comment */Comment strippedJSON has no comment syntax; JSONC does.
'name': 'Ada'Quotes normalised to doubleInternal double quotes are escaped, not dropped.
{name: 'Ada'}Property name quotedBare identifiers used as keys are wrapped in double quotes.
True, False, NoneMapped to true, false, nullPython and JavaScript spellings of the same three values.
NaN, Infinity, -InfinityReplaced with nullJSON has no representation for these numbers.
[1, 2,] or {"a": 1,}Trailing comma removedA comma may separate members but not follow the last one.
Curly quotes “ ” ‘ ’Normalised to straight quotesStraight quotes are what the JSON grammar requires.
Document stops mid-object or mid-stringOpen delimiters closedOnly the delimiters that are actually open are added.

Why assistant output breaks

A language model writes JSON the way it writes prose: with a fence around it, a sentence before it, and the occasional Python value borrowed from a code sample. None of those are valid under RFC 8259, but all of them are easy to reverse mechanically.

The difficult case is truncation. When a response hits its token limit mid-object, the text stops where the model stopped. Closing the open braces makes the text parseable, but it cannot restore the fields that were never generated. Treat a repaired truncation as a partial document, not as the complete answer.

For the reasoning behind the individual messages a strict parser produces, read JSON parse errors, decoded. If the file came from a config editor rather than a model, the failure is usually a comment or a trailing comma — the subject of why JSON5 fails.

Where to be careful

  • Duplicate keys. If the same name appears twice in one object, repair keeps both in the text. A later parser will usually keep only the last value, so check the document if duplicates matter to you.
  • Numbers like 0xFF or .5. JSON forbids them and this tool does not rewrite them into decimal, because guessing the intended number would change your data.
  • Valid but wrong. Repair only addresses syntax. A document that parses can still have the wrong types, missing fields or stale values.
  • Large integers. Repair never parses your text into a JavaScript number, so 9007199254740993 keeps its last digit. Formatting the result afterwards does the opposite — see why JSON numbers lose precision.

Frequently asked questions

What kinds of broken JSON does this fix?
It removes markdown fences and surrounding prose, strips line and block comments, replaces single-quoted strings with double-quoted ones, quotes bare property names, converts Python literals (True, False, None) and non-finite numbers (NaN, Infinity) to JSON values, removes trailing commas, normalises curly quotes, escapes literal control characters inside strings, and closes objects, arrays or strings that were cut off at the end.
How do I know what was changed?
Every edit is listed under “What changed” with its type, a plain-English description, an approximate line number and the offending snippet. Nothing is applied silently — if a document is already valid, the tool says so and changes nothing.
Will this ever guess a value or lose my data?
No. The repair only performs mechanical rewrites: quoting, normalising, removing syntax that JSON forbids and closing unmatched delimiters. It never invents a value, and it refuses to present a result unless a strict JSON.parse accepts it. When it cannot reach a valid document, it says so and shows no usable output.
Why not just use a more permissive parser?
A permissive parser (for JSONC or JSON5) accepts comments and trailing commas but not the other faults LLMs produce, such as Python literals, single quotes or a truncated tail. The goal here is to produce strict RFC 8259 JSON that any downstream tool will accept, not to read the document loosely.
Does it handle newline-delimited JSON (NDJSON or JSONL)?
No. Several objects on separate lines are not one JSON document, so a repair that joins them would change the data's meaning. Paste one record at a time, or wrap the lines in an array before using this tool.
Does repair preserve large integers exactly?
The repair step works on the text, so a 19-digit ID is never parsed into a JavaScript number and rounded. The final validation parse uses the browser's parser, but the text you get back keeps the original digits. Avoid running the result through a formatter that parses and re-serialises if those digits matter — see the precision guide below.
Is my JSON uploaded anywhere?
No. Repair, validation and display all happen in this browser tab. Nothing is sent to a server, stored in localStorage, or included in an analytics event.
JSON Formatter & ValidatorPretty-print JSON with 2 or 4 space indentation, check the syntax and copy or download the result.JSON ValidatorCheck whether a JSON document is valid and see exactly where the parser stopped.JSON MinifierStrip whitespace from JSON and see how many bytes the minified output saves.JSON Diff CheckerCompare two documents and list every added, removed and changed value with its path.JSON Escape & UnescapeTurn raw text into a JSON string value, or decode backslashes and \u escapes back into readable text.JSON to CSV ConverterTurn an array of JSON objects into a CSV file you can open in a spreadsheet.JSON to TypeScript GeneratorGenerate TypeScript interfaces from a JSON sample, with optional properties and unions inferred from every array element.JSON to Go Struct GeneratorGenerate Go structs from a JSON sample, with json tags, int64 or float64 widths, pointers for null fields and omitempty for optional keys.CSV to JSON ConverterConvert CSV to JSON with RFC 4180 parsing, delimiter detection, dotted headers unflattened into nested objects and numbers converted only when they round-trip exactly.JSON to Java POJO GeneratorGenerate Java classes from JSON: primitives for required values, boxed types for optional and nullable ones, @JsonProperty for renamed keys and nested static classes.JSON to YAML Converter (and back)Convert JSON to YAML or YAML to JSON in both directions, with multi-document support, error line numbers and YAML 1.2 typing rules.JSON to Python Class GeneratorGenerate Pydantic v2 models or dataclasses from JSON, with snake_case fields, Optional where a key is missing or null, and keyword keys renamed safely.JSON to C# Class GeneratorGenerate C# classes from JSON with nullable annotations taken from every record, initialisers that avoid CS8618 and [JsonPropertyName] for each wire key.JSON to JSON Schema GeneratorTurn a JSON sample into a draft 2020-12 schema: required keys, nullable unions and nested $defs.