UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

JSON Repair

Fix broken JSON: trailing commas, unquoted keys, single quotes, comments, smart quotes, and missing brackets — automatically.

About JSON Repair

JSON Repair is a permissive JSON parser that automatically fixes the most common reasons a JSON document fails to parse: trailing commas after the last array or object element, single-quoted strings copied from JavaScript source, unquoted keys in object literals, // and /* */ comments from JSONC files, smart curly quotes pasted from rich-text editors, missing commas between values, hex escape sequences, and unmatched braces. The tool first tries strict JSON.parse — if that succeeds, it pretty-prints the result. Otherwise it loads the jsonrepair library on-demand and reconstructs valid JSON, which is then re-parsed for verification. The list of detected issues is shown in chip form so you can see exactly what was repaired, and the final output is guaranteed parseable. Repair runs entirely in your browser; the input never leaves your machine.

Why use JSON Repair

  • Fixes Trailing Commas Automatically: The most common JSON error — a stray comma after the last array or object element — is repaired silently, so you can paste output from JavaScript or Python without manual editing.
  • Removes Comments Cleanly: // line and /* block */ comments from JSONC config files are stripped without touching surrounding values, letting you reuse VS Code settings or tsconfig.json snippets in strict-JSON tooling.
  • Quotes Bare Keys: Object literals copied from JavaScript source ({name: 'Alice'}) have their keys re-quoted and string values converted from single to double quotes, producing standards-compliant JSON.
  • Repairs Smart Quotes: Curly quotes (“ ” ‘ ’) pasted from Word, Notion, or rich-text editors are converted to straight ASCII quotes, removing the most invisible cause of parse failures.
  • Detects Missing Commas: Concatenated values like }{ or ][ get a comma inserted between them, so partially merged JSON arrays parse on the first try.
  • Browser-Only Privacy: All repair runs in your tab via the jsonrepair library — broken API responses, log dumps, and config snippets containing secrets never reach a server.

How to use JSON Repair

  1. Paste the broken JSON into the input panel — log dumps, JSONC config files, JavaScript object literals all work.
  2. The tool tries strict JSON parsing first; if that fails it auto-loads jsonrepair and fixes the input.
  3. Review the chip list under the output to see which issues were detected and repaired.
  4. Click Pretty Print to re-format the repaired JSON with two-space indentation.
  5. Use Copy Fixed to copy the valid JSON to your clipboard, ready to paste back into your code.
  6. If repair fails, fix unmatched braces or brackets manually and retry — those are the only structural errors the tool cannot guess.

When to use JSON Repair

  • Cleaning a JSON dump from a Node.js console.log() that printed object literal syntax instead of JSON.
  • Converting a tsconfig.json or .vscode/settings.json (JSONC with comments) into strict JSON for a tool that does not accept comments.
  • Repairing JSON pasted from a chat message where a word processor turned straight quotes into curly quotes.
  • Recovering JSON from a truncated log file where the trailing comma after the last entry breaks every parser.
  • Fixing JSON output from a Python repr() call that uses single quotes around strings.
  • Cleaning up JSON from a partial server response where the response was cut off before the closing bracket.

Examples

Trailing commas + comments + single quotes

Input: { // user record name: 'Alice', age: 30, roles: ['admin', 'editor',], }

Output: { "name": "Alice", "age": 30, "roles": [ "admin", "editor" ] }

Smart quotes from word processor

Input: {“user”: “Alice”, “active”: true}

Output: { "user": "Alice", "active": true }

Concatenated objects (missing comma)

Input: [{"id":1}{"id":2}]

Output: [ { "id": 1 }, { "id": 2 } ]

Tips

  • Strict JSON forbids trailing commas, but every modern JavaScript and TypeScript file allows them — repair is essential when round-tripping between code and config.
  • If the repair output still fails to parse, the original input has structural damage (missing closing brace, unbalanced brackets) — fix manually then retry.
  • JSON Lines (one JSON object per line) is not standard JSON — repair each line individually or paste the whole batch wrapped in [ and ] separated by commas.
  • Comments are a JSONC extension — they work in tsconfig.json and VS Code settings but not in JSON.parse(); use this tool to strip them before sending to strict parsers.
  • Repair preserves the original key order — useful when comparing repaired output against expected schemas in tests.

Frequently Asked Questions

Is my JSON sent to a server for repair?
No. The jsonrepair library loads from a CDN once, then runs entirely in your browser. The broken JSON you paste, including any tokens, secrets, or PII, never leaves your tab.
What kinds of broken JSON can it fix?
Trailing commas, // and /* */ comments (JSONC), single-quoted strings, unquoted object keys, smart curly quotes, missing commas between concatenated values, hex escape sequences, NaN/Infinity literals, and stray whitespace. Structurally damaged input (missing closing braces) cannot always be reconstructed.
Does it handle very large JSON files?
It works comfortably with files up to a few megabytes. Above that, browser memory and parse time become limiting factors — for multi-MB log files consider streaming line-by-line instead of single-shot repair.
What if my JSON has duplicate keys?
JSON.parse silently keeps the last value when keys are duplicated. The repair output preserves this behaviour and emits the deduplicated object — duplicate keys in input produce a single key in output with the last value.
Will it preserve the order of my object keys?
Yes. Both jsonrepair and JSON.parse preserve insertion order in modern engines, so the output keys appear in the same order as the input — useful for diffing against expected schemas.
Can it fix JSON that has been truncated mid-string?
Partially — if the truncation is at the end and only closing brackets are missing, repair adds them. If a string was cut mid-character or mid-escape, manual reconstruction is required because the intent is ambiguous.
Does it support JSON5 syntax?
Yes, most JSON5 features (single quotes, unquoted keys, trailing commas, comments, hex numbers) are repaired into standard JSON. Multi-line strings are not preserved — they are merged into single-line strings with escape sequences.
Why does the output show 'already valid' for some inputs?
If your input parses with strict JSON.parse, the tool skips repair and just pretty-prints the result. This is intentional — valid JSON should not be modified, only formatted.

Explore the category

Glossary

JSON Lines (JSONL)
A format where each line of a file is a separate JSON value, used for log streaming and large datasets. JSONL is not standard JSON — wrap lines in [ ] separated by commas to convert.
JSONC
JSON with Comments — a non-standard extension used by VS Code (settings.json, tsconfig.json) and TypeScript that allows // and /* */ comments inside JSON. Strict parsers reject JSONC; this tool strips comments to produce clean JSON.
Permissive parser
A parser that accepts non-standard or malformed input and reconstructs the intended valid value. jsonrepair is a permissive JSON parser used here to fix common errors that JSON.parse rejects.
Trailing comma
A comma placed after the last element of an array or object — legal in modern JavaScript but illegal in standard JSON. The most common cause of JSON parse failures when round-tripping with code.
Smart quotes
Curly Unicode quote characters (“ ” ‘ ’) inserted automatically by word processors. They look like normal quotes but JSON.parse rejects them — repair converts them to straight ASCII double quotes.
Bare key
An object key written without surrounding quotes, e.g. {name: "Alice"}. Legal in JavaScript object literals but illegal in JSON. Repair quotes the keys to produce valid JSON.