Repair broken JSON without guessing at missing data.
A repair is useful only when it preserves the information the author intended. Learn which syntax mistakes can be corrected automatically, why string-aware tokenization matters, and when damaged input needs a fresh source instead. Follow repair with validation and a comparison against the original before trusting the result.
Identify where the damage started
Broken JSON often starts as something that was never intended to be strict JSON. A developer adds comments to a configuration file, copies a JavaScript object from source, or pastes a console representation instead of serialized data. API response logs may also contain annotations added by logging tools rather than by the API. Establish where the text came from before deciding whether repair is appropriate or whether you should request a clean source.
Other failures indicate damaged transport or escaping rather than relaxed syntax. A truncated download can lose the end of a nested structure, and a CSV export can leave stray quotes around an embedded JSON field. In these cases, compare the response length, export settings, or original file before editing. A repair that merely produces parseable text can conceal missing records or convert an escaped field into the wrong value.
Match the supported repair scope
CurlyBrackit's repair handles five common syntax mistakes: trailing commas, single-quoted strings, unquoted object keys, missing commas between properties, and comments. Comments can use either double slashes or a slash-star block. These corrections target familiar deviations from strict JSON rather than inventing a new data model. Use the JSON repair page at /json-repair when those mistakes explain the parser failure and the surrounding values remain available for inspection.
Each category still needs a clear interpretation. A trailing comma is punctuation after the last member or element, not a comma inside a string. An unquoted key occurs where an object property name belongs, not wherever a word appears. A missing comma between properties can be inserted when token boundaries make the intended separation clear. Repair is safest when it changes syntax around intact values rather than reconstructing damaged content.
Preserve strings with tokenization
A tokenizer reads the input as meaningful units while tracking whether the current characters belong to a string, an escape sequence, a comment, or structural punctuation. That context prevents syntax-looking text inside strings from being treated as syntax. A global replacement has no such understanding. Replacing every apostrophe with a double quote can break a person's name, while removing everything after double slashes can cut a URL in half.
For example, an ordinary JSON string containing O'Reilly already contains a legal apostrophe and needs no correction. A string containing https://example.com/a also contains no comment despite the slashes. CurlyBrackit's repair tokenizes the input so those string contents are preserved. If the source uses ambiguous unescaped quotes that obscure where a string ends, verify the original value instead of assuming any automated interpretation must match the author's intent.
Refuse to invent missing information
A repairer should not guess missing closing braces at the end of a truncated file. Adding punctuation could make the remaining prefix parse, but it cannot establish whether more fields or array elements were lost. Retrieve the original response or download again when possible. If only a partial document survives, label any manually recovered subset as partial instead of presenting it as a repaired copy of the complete source.
Ambiguous nesting and absent values require the same restraint. A missing delimiter can leave several plausible parents for a property, and a key without a value does not tell you whether the intended value was null, an empty string, or a number. Inserting a convenient default changes data. Consult the producing application, the schema, or a trusted original, and record any deliberate reconstruction separately from automatic syntax cleanup.
Repair first, then validate
Keep an untouched copy before repair, especially when the text comes from an incident report or a production export. Paste or import the working copy, inspect the initial parser message, and run repair only when the diagnosed mistakes fit its supported scope. CurlyBrackit processes the content in the browser without uploading it to a server, and it works offline once loaded. File imports are limited to 10 MB.
Next, validate the repaired text as JSON and inspect any remaining parser error before proceeding. Successful parsing proves grammatical validity, not correctness of the values. If you have a schema, validate against that contract as a separate check for missing fields, unexpected types, and prohibited values. A document can be valid JSON while still describing an impossible age or omitting an identifier required by the receiving application.
Review the diff and fix the producer
Finally, diff the repaired result against the original and account for every changed region. Check that removed comments were actually outside strings, that apostrophes and URLs survived, and that added commas did not shift your understanding of object boundaries. Review record counts and important identifiers against the source when available. A successful parse and a green schema result are useful evidence, but neither proves that the original information survived intact.
For a readable comparison, keep the original unchanged and beautify a separate repaired copy with two-space indentation. Avoid combining syntax cleanup with key renaming, bulk replacement, or value normalization, because unrelated edits make the diff harder to audit. Once the repaired payload is accepted, correct the producer by using a real JSON serializer or fixing the export pipeline. Repeated manual repair should not become a substitute for reliable serialization.
Related tools
Frequently asked questions
Which mistakes can automatic repair correct?
CurlyBrackit's repair handles trailing commas, single-quoted strings, unquoted object keys, missing commas between properties, and line or block comments. These are syntax corrections around available content, not a way to recover values or records absent from the input.
Will repair damage apostrophes or URLs?
CurlyBrackit's repair tokenizes the input rather than applying global replacements, so apostrophes and URLs inside strings are preserved. You should still compare the result with the original, especially when malformed quoting makes the intended string boundaries unclear.
Should I add closing braces to a truncated response?
Not as an automatic recovery step. Closing the remaining structure may create valid JSON while hiding missing fields or records. Retrieve the complete response when possible, or clearly identify any manually recovered portion as incomplete rather than equivalent to the original.