How to use Fix JSON
- 1. Paste broken JSON. Trailing commas, // comments, and single quotes are typical.
- 2. Click Repair. The tool parses with JSON5 rules and re-emits strict JSON.
- 3. Review the output. Repair can change meaning if the input was ambiguous — always diff important configs.
About this tool
“Fix json” is an emergency query: something is red in CI and you need it green. This page leads with Repair, not pretty-print, because the user’s document probably does not parse yet.
What Repair fixes
Trailing commas before } or ], single-quoted strings, unquoted object keys, and // or /* */ comments. It does not invent missing brackets or guess truncated files.
After repair
Run through the validator, then pretty-print for review. For production configs, commit the repaired strict JSON, not the sloppy original.
Code examples
JavaScript
const payload = JSON.parse(raw);
console.log(JSON.stringify(payload, null, 2));Python
import json
print(json.dumps(json.loads(raw), indent=2, sort_keys=True))Go
var buf bytes.Buffer
if err := json.Indent(&buf, []byte(raw), "", " "); err != nil {
log.Fatal(err)
}