FormatterHQ

JSON Fixer & Repair

Paste JSON that will not parse and get valid, formatted JSON back. Quotes, commas, comments, Python literals and missing closing brackets are fixed automatically.

Input JSON
Output JSON
Ready.

How to use the JSON Fixer & Repair

  1. Paste the broken JSON, upload the file, or click Sample to see a document with several typical mistakes.
  2. Choose the Indent for the repaired output.
  3. Click Repair JSON. The status bar says whether a repair was needed.
  4. Review the result, especially around values that were guessed, then copy or download it.

A JSON fixer for almost-JSON

A lot of text that looks like JSON is not quite JSON: a JavaScript object literal, a Python dictionary printed with print(), a response cut off by a log limit, or a config file with comments. This JSON fixer rewrites such input into strict JSON and then formats it, so you do not have to hunt for each problem one error message at a time.

Repairs are done by the open-source jsonrepair library, running in your browser.

Example

This snippet has five separate problems:

{
  name: 'Northwind',   // company
  "tags": ["api", "saas",],
  "active": True,
  "owner": {"name": "Priya" "email": null}
}

After Repair JSON:

{
  "name": "Northwind",
  "tags": [
    "api",
    "saas"
  ],
  "active": true,
  "owner": {
    "name": "Priya",
    "email": null
  }
}

What gets fixed

ProblemBeforeAfter
Unquoted or single-quoted keys and strings{name: 'Ana'}{"name": "Ana"}
Trailing and missing commas[1 2 3,][1, 2, 3]
Line and block comments{"a":1,/* c */"b":2}{"a": 1, "b": 2}
Python constantsNone, True, Falsenull, true, false
Truncated document{"a":1,"b":[1,2{"a": 1, "b": [1, 2]}
Missing colon or value{"a" 1, "b":}{"a": 1, "b": null}
Unescaped quotes inside a string"he said "hi"""he said \"hi\""
Curly quotes from word processors“curly”"curly"

It also strips wrappers that often surround JSON: Markdown code fences (```json), a JSONP callback such as callback({...});, and MongoDB-style ObjectId("...") calls, which become plain strings. Several objects on separate lines are combined into one array, and a stray extra closing bracket at the end is dropped.

Review guessed values

Some inputs have more than one reasonable fix, and the repair picks one. A few worth knowing:

  • NaN and hexadecimal numbers such as 0x1F become strings ("NaN", "0x1F"), and undefined becomes null.
  • Two commas in a row inside an array can change the structure: [1,,2] comes out as [[1], 2]. Fix such spots by hand.
  • Plain text with no JSON structure at all is turned into a single JSON string rather than rejected.
  • A truncated string is closed where the input ends, so the last value may be incomplete.

When repair fails

If the damage is ambiguous, the tool stops with "Could not repair JSON" and the position, for example Object key expected at position 7 (line 1, column 8) for {"a":1,,"b":2}. Text after the end of a complete document, like {"a":1} garbage, is also reported. Remove the offending characters at that position and repair again.

If the input was already valid, you see "JSON was already valid — formatted it." and nothing but whitespace changes.

Fixer or formatter?

Use the JSON validator when you want to know what is wrong, for instance to fix the program that produced the data. Use this fixer when you just need usable JSON now. If the file is meant to keep comments and trailing commas, it is probably JSON5; the JSON5 formatter keeps it in that format. To strip the empty fields out of the repaired result, continue with the JSON cleaner.

Privacy

Repair runs in your browser, and the pasted text is not uploaded. Load URL and Save & Share are the only features that use our server.

JSON fixer in Python

The json module reports errors but never repairs them, so a general fixer needs the third-party json-repair package: repair_json() takes the broken text and returns valid JSON, coping with unquoted keys, single quotes, trailing commas, comments, missing commas and unclosed brackets. The shortcut people try first, text.replace("'", '"'), breaks as soon as a value contains an apostrophe, as in O'Neil. When the text is really a printed Python dictionary, ast.literal_eval() from the standard library reads it safely and json.dumps() writes it back as JSON.

# pip install json-repair
import ast
import json
from json_repair import repair_json

broken = """{name: 'Northwind Labs', "tags": ["api", "saas",], "active": True, // note
 "owner": {"name": "Priya" "email": "priya@example.com"}"""

fixed = repair_json(broken)           # returns valid JSON text
data = json.loads(fixed)
print(json.dumps(data, indent=2))

# A printed Python dict needs no package: literal_eval reads it safely
printed = "{'id': 7, 'name': \"O'Neil\", 'active': True, 'manager': None}"
print(json.dumps(ast.literal_eval(printed)))
# {"id": 7, "name": "O'Neil", "active": true, "manager": null}

A repair is always a guess, so paste the same text above and compare the two results before relying on either.

Frequently asked questions

Can a JSON fixer repair any broken file?
No. It fixes the common, unambiguous mistakes: quoting, commas, comments, literals and missing closing brackets. Heavily damaged input, such as doubled commas between object members or random text after the document, is reported with its position so you can fix it by hand.
Will repairing change my data?
Valid parts stay the same, but guessed repairs can alter values: NaN and hex numbers become strings, undefined becomes null and a truncated string is closed where it ends. Compare the output with the input before using it.
Can it fix JSON copied from ChatGPT or Markdown?
Yes. Markdown code fences such as ```json around the document are removed, and typographic curly quotes are converted to straight double quotes.
How do I fix a Python dictionary printed as text?
Paste it and click Repair JSON. Single quotes become double quotes and True, False and None become true, false and null. Using json.dumps in Python avoids the problem at the source.
Why do large numbers change after repair?
The repaired text is parsed with JavaScript, which stores numbers as doubles. Integers above 9,007,199,254,740,991 are rounded. Keep long IDs as strings in the source data.

Last updated October 3, 2026

Guides

Related tools

JSON Flatten Flatten nested JSON into single-level key paths like user.address.city, with dot, custom or bracket notation for arrays. JSON Formatter Format, beautify and validate JSON online. Pretty print minified JSON with 2, 3, 4 space or tab indentation and pinpoint syntax errors. JSON Merge Patch (RFC 7396) Apply an RFC 7396 JSON Merge Patch to a document, or create the merge patch that turns one JSON document into another. JSON Minify Minify JSON by removing whitespace and line breaks. Shrink payloads for APIs, storage and embedding, and see the bytes saved. JSON Multiline String Converter Convert multi-line text into a valid JSON string with \n escapes, a JSON array of lines, or concatenated string literals. JSON Navigator Navigate JSON by path. Browse or filter the tree and click any key to see and copy the full path to that value. JSON Parser Parse JSON online: errors with line and column, the parsed values with their types, and the pitfalls of big integers and duplicate keys. JSON Patch Tester (RFC 6902) Apply RFC 6902 JSON Patch operations (add, remove, replace, move, copy, test) to a document and see exactly which step fails. JSON Patch Generator (Diff to Patch) Compare two JSON documents and generate the RFC 6902 JSON Patch that transforms the first into the second, with optional test ops. JSON Path Finder Click any value in a JSON tree to get its path as JSONPath, JavaScript, Python, PHP, jq or JSON Pointer — or list every path. JSON Pretty Print Pretty print JSON online with a 4-space default, 2 or 3 spaces or tabs, and see the matching JavaScript, Python, PHP and jq commands. JSON Reader Open a .json file in your browser and read it as a collapsible tree, a sortable table or a graph, with a filter to find any value.