Repair invalid JSON online

How online JSON repair, cleaning and validation tools change your data, when a repaired result is safe to use, and when to fix the source by hand instead.

Tools that promise to clean, correct or repair JSON online do several different jobs under similar names. Some only check whether text is valid JSON. Some only change whitespace. Others rewrite characters to turn malformed input into something a parser will accept. These jobs carry very different risks. This review explains what each one changes, when a repaired result can be trusted, and when to fix the source yourself. It covers repair tools as a category, not any specific named service. No particular tool was tested for this article, and claims about a tool's accuracy, size limits or data handling should be checked against that tool's own documentation.

Is an online JSON repair tool suitable for your use?

Repair is a reasonable choice when the intended content is obvious and only the syntax is wrong. Typical cases are a JavaScript object literal pasted where JSON was expected, a config snippet with comments, or generated output with a stray trailing comma. The main benefit is speed. The tool applies routine fixes so you don't have to hunt for each one.

The key tradeoff is that a repair tool has to guess. When the input is ambiguous, the tool picks one interpretation and returns output that parses cleanly. Nothing in that output tells you a guess was made. Valid syntax does not prove the data is correct.

In some situations it is better to keep the original text and fix the problem at its source:

  • The data is authoritative, such as financial records, API contracts or anything another system depends on, and a silent change would be costly.
  • The input may be truncated. A repair tool can close open brackets and produce valid JSON that is missing data.
  • The file is meant to be JSON5 or JSON with comments, as some configuration formats allow. Converting it to strict JSON removes comments that the file's owner expects to keep.
  • The content includes secrets, credentials or personal data, and you have not confirmed how the online service handles what you paste.
  • The invalid JSON comes from a program you control. Fixing the serializer stops the error from happening again. Repairing each output only hides it.

What "clean", "correct" and "repair" actually change

These words are used loosely, so it helps to separate the operations by whether they change the stored characters, the data's meaning, or only how the text looks on screen.

Operation | Changes stored characters? | Can change data meaning?
Validation (syntax check) | No, it only reports errors and their positions | No
Formatting (pretty-print or minify) | Yes, but only whitespace between tokens | No, if the input was already valid
Syntax highlighting, tree or collapsible view | No, display only | No
Repair (fixing invalid syntax) | Yes: quotes, commas, literals, escapes, brackets | Yes, whenever the tool has to guess
Re-serializing through a parser | Yes, the whole document is rewritten | Possibly: duplicate keys, number precision, key order

Formatting and display features are presentation. Pretty-printing adds indentation. Minifying removes it. Color highlighting and tree views affect only what you see in the tool. None of these touch the values. Repair is different. It edits the text so that it follows the JSON grammar defined in RFC 8259. That grammar requires double-quoted strings and keys and has no comments or trailing commas. Its only literals are true, false and null, and NaN, Infinity and undefined are not allowed.

Here is an illustrative malformed input with four common problems: an unquoted key, a single-quoted string, a comment and trailing commas, plus a Python-style boolean.

{
  name: 'Ada',
  // added by hand
  "tags": ["admin", "editor",],
  "active": True,
}

A typical repair would produce the following:

{
  "name": "Ada",
  "tags": ["admin", "editor"],
  "active": true
}

Each change in this example matches a single grammar rule. The key and the string get double quotes, the comment and trailing commas are removed, and True becomes true. Even so, two of these edits are judgment calls. The comment is lost for good. Rewriting True as true assumes the author meant a boolean. A different tool could reasonably have produced the string "True" or rejected the value instead. Single-quoted strings that contain double quotes or apostrophes need escaping when converted, and that is a common source of repair mistakes. Compare the repaired output with the original before using it.

Changes that happen even when the JSON was valid

Many online tools parse the input and then serialize it again, even if you only asked for formatting. That round trip can change data without any repair taking place:

  • Large integers: parsers built on JavaScript store numbers as 64-bit floating point. Integers larger than 2^53 can lose precision, so long IDs may be quietly altered.
  • Duplicate keys: RFC 8259 says object names should be unique but leaves duplicate handling to the implementation. Many parsers keep the last value and drop the earlier ones without warning.
  • Number formatting: forms such as 1.0 or 1e2 may come back written differently. The value is usually the same, but any comparison that relies on exact text will fail.
  • Key order: some tools sort keys. JSON does not give key order any meaning, but people reading the file or tools comparing text may depend on it.

If any of these matter for your data, a tool that only changes whitespace is safer than one that parses and re-serializes. A side-by-side diff of the input and output is the most reliable check.

Will the result stay usable after copying and sharing?

JSON is plain text, so a valid result usually copies and pastes intact. Problems tend to come from the route the text takes before it reaches the tool. Word processors, chat apps and some note-taking tools can change characters in ways that break JSON even though the text looks normal:

  • Typographic quotes (“ and ”) replacing straight double quotes. They look nearly the same, but JSON does not accept them as string delimiters.
  • Non-breaking or other Unicode spaces between tokens. RFC 8259 allows only space, tab, line feed and carriage return there.
  • A byte order mark at the start of a file. The standard says generators must not add one. Parsers may ignore it, but they are not required to.
  • Literal line breaks or tabs inside a string value. JSON requires these to be escaped as \n and \t.
  • Zero-width characters picked up during copying. They are invisible in most editors and can produce errors that are hard to locate.

If a validator reports an error at a spot where the text looks correct, one of these invisible or look-alike characters is a likely cause. Retyping the character usually fixes it, and so does an editor setting that shows invisible characters. To share JSON safely, send it as a file or in a code block rather than as formatted text in a document.

On accessibility, color highlighting and collapsible trees exist only inside the tool. They are lost when you copy the text out. A tool that signals errors only with color will be hard to use for anyone who cannot rely on color. A written message giving the line and column is more useful to everyone. No evidence was available on how particular online JSON tools work with screen readers, so check that against each tool's accessibility documentation or test it with your own assistive technology. Pretty-printed output with consistent indentation is generally easier to read and edit than minified text, both on screen and in a plain-text editor.

Privacy and local alternatives

Pasting JSON into a web page may send it to a server, or the processing may happen entirely in your browser. A tool's appearance or marketing does not reliably tell you which. If the data is sensitive, look for a clear, documented statement of how input is processed and retained. If you can't find one, use a local tool instead. Two common command-line options validate and pretty-print without sending data anywhere:

python3 -m json.tool data.json
jq . data.json

Both report errors with a position you can look up, and neither rewrites invalid input on its own. Parsers also disagree at the edges. For example, Python's json module accepts NaN and Infinity by default, even though standard JSON does not allow them. Passing one validator therefore does not guarantee that every consumer will accept the file. If you know which system will read the data, validate with that system's parser, or with a JSON Schema check when structure matters as well as syntax.

Bottom line

An online repair tool works well for quickly turning nearly-valid, low-stakes JSON into a parseable form, provided you review what it changed. Formatting and validation are safer because they do not alter values. Repair and any parse-and-reserialize step can change data silently. For authoritative, truncated, sensitive or deliberately non-standard input, keep the original text, find the exact error with a validator, and correct it by hand or fix the program that produced it.