JSON Repair

Turn almost-JSON into valid JSON: JavaScript objects, Python dicts, JSON with comments, copied log lines and truncated responses are repaired, and every fix is listed.

S'executa al teu navegador. Els fitxers mai no surten del dispositiu. Mira com comprovar-ho

…

Com es fa

  1. 1
    Paste the input

    Paste the broken JSON.

  2. 2
    Read the fixes

    Check the list of repairs.

  3. 3
    Check the result

    Compare it with what was meant.

  4. 4
    Choose formatting

    Indented or minified.

  5. 5
    Copy or download

    Save the valid JSON.

  6. 6
    Validate

    Use it in your code or API call.

Sobre aquesta eina

JSON parsers are strict: one trailing comma, a single quote or a comment and the whole document is rejected with an unhelpful "Unexpected token". Yet a lot of real-world data is almost JSON: JavaScript object literals copied from code, Python dictionaries printed to a log, configuration files with comments, AI-generated output with smart quotes, or an API response cut off in the middle. This repair tool parses such input tolerantly and produces valid JSON. It removes comments and trailing commas, adds missing commas and colons, quotes unquoted keys and words, converts single, backtick and typographic quotes, translates Python True, False and None and JavaScript undefined, replaces NaN and Infinity (which JSON cannot represent) with null, and closes strings, arrays and objects left open by truncation. Each kind of fix is listed, with line numbers where useful, so you can check that the repair matches what was meant.

What gets fixed

- Comments: // line, /* block */ and # comments. - Commas: trailing commas, doubled commas, and missing commas between items. - Quotes: single quotes, backticks and “smart” quotes become standard double quotes. - Keys: unquoted keys such as name: are quoted. - Values: True/False/None (Python), undefined, NaN, Infinity, hex numbers, leading + signs and .5-style numbers. - Structure: missing colons, = used instead of :, wrong closing brackets, and strings, arrays or objects left open at the end. - Byte-order marks and text after the end of the JSON.

Checking the result

Repairs are guesses about intent. Truncated input is closed where it stopped, so data after the cut is missing; NaN becomes null; an unquoted word becomes a string. Read the list of fixes and compare the result with the source, especially for anything cut off.

Already valid?

If the input is already valid JSON, the tool says so and simply reformats it with your chosen indentation.

Typical uses

- Turning a JavaScript or Python literal into JSON for an API call or test fixture. - Recovering data from a truncated log line or a timed-out response. - Cleaning JSON produced by language models, which often adds trailing commas or smart quotes. - Converting JSON5-style configuration into strict JSON.

Strict JSON reminders

JSON allows only double-quoted strings, no comments, no trailing commas, no NaN or Infinity, and keys must be strings. If you control the format, JSON5 or YAML may suit hand-edited files better.

Limits

Severely garbled input can only be partly recovered. Duplicate keys keep the last value, as JSON.parse does. Very large inputs are slow in the browser. Always validate repaired data before using it in production; this is a convenience tool, not a data-recovery guarantee.

Exemple resolt

A JavaScript object with a comment, unquoted keys, a trailing comma, True and NaN becomes '{"name": "Ada", "tags": ["a", "b"], "active": true, "score": null, "note": "smart quotes"}', with six fixes listed including the missing comma between "a" and "b".

En resum

Preguntes freqüents

What kinds of broken JSON can it fix?

Comments, bad commas, wrong quotes, unquoted keys, Python and JavaScript values, NaN and truncated input.

Can it recover a cut-off response?

It closes what was open; data after the cut is missing and is not invented.

Why did NaN become null?

JSON has no NaN or Infinity; null is the closest valid value.

Does it change valid JSON?

No, it only reformats it.

Is my data uploaded?

No. Repair runs in your browser.

Can I get minified output?

Yes. Choose minified as the indent.

Totalment gratisSense cost, sense registre
Els fitxers es mantenen privatsTot funciona al teu navegador
Fàcil en el teu idiomaDisponible en molts idiomes