JSON Repair: Fix Invalid JSON Online

What a JSON fixer changes, when automatic repair is safe, where it can silently alter data, and how to check repaired JSON before you use it.

A JSON fixer takes text that a strict parser rejects and rewrites it until it parses. That is useful when you need to recover a broken payload quickly, but repair differs from formatting. A repair tool changes the characters in your data, and some of those changes involve guesses. This review explains what JSON repair does, when it is suitable, and how to confirm that the repaired output still means what the original meant.

Is a JSON fixer suitable for your use?

Automatic repair works well when the original intent is obvious and the problems are syntax rather than content. Typical examples are a trailing comma, single quotes instead of double quotes, unquoted keys, or comments pasted from a config file. In those cases the main benefit is speed. You get parseable JSON without hunting through a long blob by hand.

The decisive tradeoff is that a repaired document can be valid and still be wrong. When the damage is ambiguous, the tool has to pick one interpretation. Truncated input and unescaped quotes inside strings are the usual cases. The parser will accept the result, so nothing warns you that the guess was incorrect.

Fixing by hand, or fixing the source, is the better choice in these situations:

  • The JSON comes from a program you control. Repairing its output hides a bug that will recur.
  • The input was cut off, for example by a log line limit, a network timeout or a copy that missed the end. Closing the brackets produces a smaller document, not the original one.
  • The data feeds billing, permissions, migrations or anything else where a silent change matters.
  • The file is meant to be JSONC or JSON5, such as an editor or build config that allows comments. Converting it to strict JSON can delete comments that people rely on.
  • The content is sensitive and you cannot confirm how an online tool handles submitted text.

What JSON repair actually changes

Three kinds of tools often share the labels "fixer" and "formatter," and they behave very differently:

Operation | What changes | Effect on data
Validation | Nothing; it reports whether the text parses and where it fails | None
Formatting (pretty-print or minify) | Whitespace between tokens only, for input that is already valid | None, if the tool rearranges tokens instead of re-serializing values
Repair | Characters are added, removed or replaced: quotes, commas, brackets, literals, comments | Can change structure or values when the original was ambiguous

If you searched for a "JSON format fixer," work out which of these you need. Valid JSON that is hard to read only needs a formatter. Text that a parser rejects needs repair or a manual fix.

Strict JSON is defined by RFC 8259 and ECMA-404. Repair tools usually target the gaps between those rules and how people actually write JSON-like text. A common case is input copied from JavaScript or Python:

{name: 'Ada', "tags": ["a", "b",], // primary user
 "active": True, "manager": None}

This input breaks several rules. The key is unquoted, a string uses single quotes, an array has a trailing comma, there is a comment, and the literals use Python capitalization instead of true and null. A plausible repair is:

{"name": "Ada", "tags": ["a", "b"], "active": true, "manager": null}

Every change here is mechanical, and the meaning holds up. The exception is the comment, which is gone because strict JSON has no place for it. Different tools may handle it differently, so treat this as an illustration, not a description of any particular product.

Ambiguous damage is a different situation:

{"items": [1, 2, 3

A tool can close this as {"items": [1, 2, 3]}, and the result will parse. Nothing in the input shows whether the array originally ended at 3. Unescaped quotes are similar. In "note": "She said "ok" twice", the tool cannot know for certain where the string was meant to end. Whatever it chooses, the output looks equally valid.

Some tools work by parsing the input and then serializing it again, and that can change valid parts of the document too. Watch for these changes:

  • Large integers. Values beyond 2^53 can lose precision when parsed into a standard double-precision number, as in JavaScript.
  • Number spelling. Values such as 1.0 or 1e2 may come out as 1 or 100.
  • String escapes. An escape such as \u00e9 may be rewritten as the literal character é, or the reverse. The string value is the same but the bytes differ, which matters for signatures and hashes.
  • Duplicate keys. RFC 8259 says object names should be unique but does not require it. Parsers differ on which value they keep, and re-serializing typically drops the others.
  • NaN and Infinity. These are not valid JSON. A repair tool may turn them into null, into strings, or reject them, and each choice means something different.

Will the result stay usable after copying or sharing?

Many "invalid JSON" errors come from the copy itself, not from the data. Text pulled from word processors, chat apps, PDFs or web pages can bring in characters that look correct but are not valid JSON syntax:

  • Curly quotes (“ ” ‘ ’) instead of the straight double quote that JSON requires.
  • Non-breaking spaces (U+00A0) or other Unicode spaces. JSON allows only space, tab, line feed and carriage return as whitespace between tokens.
  • Zero-width characters, which are invisible in most editors.
  • A byte order mark at the start of the file. RFC 8259 says implementations must not add one and may ignore one, so some parsers reject it.

A repair tool may normalize these characters silently. Inside a string value, that is a change to your data. If the exact characters matter, compare the output with the original rather than assuming the tool only touched syntax.

Readability helps with review. Minified JSON is hard to scan visually, and it is likely to be hard to navigate with a screen reader as well. Pretty-printed output with consistent indentation makes structure easier to follow and makes diffs meaningful. This article cites no testing with specific assistive technologies, so treat that as a general expectation, not a verified result.

Repaired JSON also has to be accepted by the system that receives it. Strict JSON is the safest target. A destination that expects JSON5, JSONC or a specific schema can still reject valid JSON, or accept it with different semantics. Test against the actual consumer instead of relying on one successful parse.

Checking a repair before you trust it

  • Parse the output with the strict parser your application actually uses, not only the tool's own validator.
  • Diff the original against the repaired text. Every change should be one you can explain.
  • Check the end of the document. If the tool added closing brackets or braces, assume data may be missing until you confirm otherwise.
  • Validate against a schema, if one exists, so that structural guesses show up as errors.
  • Spot-check long numbers, escaped strings and any keys that appear twice.
  • When the source is a program you maintain, fix the serializer as well, so the repair is not needed next time.

Privacy and what this review does not cover

An online JSON fixer receives whatever you paste into it. How a given tool processes, logs or retains that text can only be known from its documented policy, or from confirming that it runs entirely in the browser. A clean interface or a "secure" label does not establish either. For API keys, tokens, personal data or internal payloads, use a local editor, a command-line parser or a library in your own environment.

This article does not evaluate any specific JSON repair product. No tool-specific features, accuracy figures or test results were available, so the behaviors above describe what repair tools commonly do and what the JSON specification permits. Check the documentation and actual output of the tool you choose.