JSON Repair Online – Fix Invalid JSON

Repair common JSON syntax problems locally, review every change, and compare the fixed output before you use it.

Runs locally
Ready to repair

Paste malformed JSON or AI-generated structured output.

56 chars

Run the repair to preview the corrected document.

0 chars

Try a focused case

Common invalid JSON examples

Load one broken syntax pattern at a time, run the repair, and compare the declared rule with the resulting repair log.

Trailing commas

Trailing comma

Remove commas that appear immediately before closing object or array delimiters without touching commas stored inside string values.

{"roles":["admin","editor",],"active":true,}

Review: Confirm that each removed comma was only formatting punctuation and did not represent an intentionally missing value.

JavaScript-style object

Trailing comma · Single-quoted string · Unquoted object key

Convert identifier-like keys and single-quoted strings from a JavaScript object literal into standard JSON syntax.

{
  name: 'VetaTool',
  features: ['repair', 'diff',],
}

Review: Review every inferred key and string boundary because apostrophes and JavaScript escaping can make the intended text ambiguous.

JavaScript comments

JavaScript comment

Remove line and block comments that are legal in some configuration formats but are not allowed by the JSON grammar.

{
  // feature flag
  "enabled": true /* temporary rollout */
}

Review: Check whether a removed comment contained operational context that should be preserved outside the repaired JSON document.

Markdown code fence

Markdown code fence

Strip one outer Markdown fence commonly added around JSON returned by chat assistants, documentation, or copied code blocks.

```json
{"name":"Ada","active":true}
```

Review: Verify that the fence wrapped the entire payload and that no explanatory prose outside the code block was discarded.

Unsupported JavaScript literals

Undefined value · Non-finite number

Replace undefined and non-finite numbers that JavaScript accepts but standard JSON cannot represent with reviewable null placeholders.

{"missing":undefined,"score":NaN,"limit":Infinity}

Review: Decide whether null is the correct business value, or whether the property should be removed or represented another way.

Missing and redundant commas

Missing comma · Redundant comma

Insert a separator between adjacent complete values and remove extra separators only where surrounding tokens identify the boundary.

{"first":1 "second":2,,"third":3}

Review: Confirm that inferred separators match the intended property boundaries and that no omitted value was represented by an empty slot.

Mismatched delimiters

Mismatched delimiter

Replace or add a closing brace or bracket when the nested token stack identifies one bounded structural mismatch.

{"items":[1,2,3}

Review: Inspect the surrounding nesting because heavily damaged objects can have more than one plausible brace or bracket completion.

Escaped JSON string

Escaped JSON string

Decode one outer JSON string layer when a field contains an escaped object or array instead of a directly nested JSON value.

{"payload":"{\"name\":\"Ada\",\"active\":true}"}

Review: Confirm that the field is intended to become a nested object rather than remain a string consumed by another downstream system.

Repair log

Run the repair to see each change and why it was made.

No repair run yet.

JSON repair guide

How JSON repair works

Paste malformed JSON into the repair workspace above and start one explicit repair pass. VetaTool applies conservative syntax corrections, validates the result, and shows both a change log and a line-by-line diff so you can review every modification before copying the output.

Steps

  1. Paste malformed JSON into the input panel.
  2. Select Repair JSON to run the supported corrections in a stable order.
  3. Review every item marked Review required before trusting the repaired values.
  4. Compare the diff, then copy the output only after it validates as standard JSON.

Repairs stay visible and reviewable

JSON Repair records the rule, source position, original text, replacement, and reason for every change. Deterministic cleanup is marked Automatic, while corrections that may change meaning are clearly marked Review required.

The output is validated again after all repair rules run. If unsupported syntax remains, the workspace keeps the candidate output and displays the remaining parser error instead of claiming success.

Common syntax handled by the first release

The repair pipeline can remove trailing commas, JavaScript comments, and Markdown code fences; quote common object keys and single-quoted strings; replace unsupported JavaScript literals; repair selected separators and delimiters; and decode nested escaped JSON objects or arrays.

  • Automatic changes are limited to deterministic syntax cleanup.
  • Ambiguous changes remain visible and require human review.
  • Business fields, duplicate keys, and unknown data are never invented silently.

Practice with focused malformed JSON examples

The workbench includes focused examples for each supported repair family. Load a single pattern to see which rule runs, whether the change is automatic or review-required, and how the same correction appears in the repair log and line diff.

  • Trailing commas, JavaScript-style keys and strings, and comments.
  • Markdown fences, undefined values, and non-finite numbers.
  • Missing or redundant separators, mismatched delimiters, and escaped nested JSON.

Repair sensitive JSON in the browser

The repair pipeline, validation, change report, and diff run locally in the browser. Large inputs use the same browser Web Worker path as other VetaTool data tools, so the payload is not sent to a repair service.

JSON repair example

The input uses an unquoted key, a single-quoted string, and a trailing comma. Each correction appears separately in the repair log.

Malformed JSON

{
  name: 'Ada',
  active: true,
}

Repaired JSON

{
  "name": "Ada",
  "active": true
}

Common questions

Frequently asked questions

Does JSON Repair change data silently?

No. Every supported change appears in the repair log. Corrections that may affect meaning are marked Review required.

Will every invalid JSON document be repaired?

No. The tool only applies registered, bounded rules. Unsupported or ambiguous syntax remains visible with a parser error for manual correction.

What is the difference between JSON Repair and JSON Validator?

The validator reports whether syntax is valid. JSON Repair creates a reviewable corrected candidate and shows exactly what changed.

Can JSON Repair fix AI-generated JSON?

It can repair supported syntax patterns often found in model output, including Markdown code fences, trailing commas, JavaScript-style keys and strings, unsupported literals, and selected separator or delimiter errors. Unsupported ambiguity remains visible for manual correction.

What happens to undefined, NaN, and Infinity?

Standard JSON cannot represent those JavaScript values. VetaTool replaces them with null placeholders and marks every replacement Review required so you can choose the correct business representation.

Can JSON Repair remove comments and Markdown code fences?

Yes. Complete JavaScript comments outside strings and one outer JSON Markdown fence are deterministic cleanup rules. Comment-like text inside quoted strings is preserved.

What happens to duplicate JSON keys?

Duplicate keys are not merged, renamed, or silently removed. Their intended meaning depends on the producer and consumer, so they remain in the candidate output for explicit review.

Is malformed JSON uploaded to a server?

No. Repair, validation, reporting, diff generation, and the common-error examples run locally in your browser.