How to repair malformed and broken json automatically
- Step 1Paste or drop the broken JSON — Paste the malformed JSON into the input, or drop a
.json,.ndjson,.jsonl, or.txtfile onto the dropzone. The file is read locally withfile.text()— nothing is uploaded. - Step 2Pick the output indent — Choose 2 spaces or 4 spaces for the re-serialized output. These are the only two indent options exposed; the fixer always normalizes whitespace by re-running
JSON.stringifyonce parsing succeeds, so your original indentation is replaced by the chosen one. - Step 3Click Fix JSON — The tool first tries
JSON.parseon the input as-is. If that works, you get clean re-indented output with zero fixes. If it throws, the five repair passes run in order and parsing is retried. - Step 4Read the Fixes applied list — Each pass that changed the text adds a line:
Removed trailing commas,Replaced single quotes with double quotes,Added quotes to unquoted object keys,Replaced undefined with null,Added missing commas between elements. If the input was already valid you'll seeNo fixes needed. - Step 5Check the validity banner — Green Fixed & valid JSON means the output passed
JSON.parse. Yellow Partially fixed means the five passes ran but the result still doesn't parse — the output is the best-effort text, not guaranteed-valid JSON. - Step 6Copy, download, or escalate — Copy the result to the clipboard or download it as
<name>.fixed.json. If the banner is yellow, paste the partially-fixed output into the JSON validator to get the exact line and column of the remaining error and fix it by hand.
The five repair passes, in order
Exactly what the fixer changes, the regex behind each pass, and the label it reports. Passes run top to bottom; the file is re-parsed only after all five have run.
| Pass | What it changes | Reported label |
|---|---|---|
| Single quotes → double quotes | 'key': and : 'value' become "key": and : "value". Keys matched after {, ,, or [; values matched after a colon. Value match is '([^']*)' — it stops at the first inner apostrophe | Replaced single quotes with double quotes |
| Quote unquoted keys | Bare keys matching [a-zA-Z_$][a-zA-Z0-9_$]* after { or , get wrapped in double quotes. name: → "name": | Added quotes to unquoted object keys |
| Strip trailing commas | Any , followed by optional whitespace then } or ] is removed. Handles 1,}, 1, ], and 1,\n} | Removed trailing commas |
| undefined → null | An undefined VALUE becomes null, string-aware: the pass walks the text tracking string state, so the word undefined inside a quoted string value is preserved | Replaced undefined with null |
| Missing commas between elements | A } or ] followed by a newline then {, [, a word char, ", or ' gets a comma inserted: }\n{ → },\n{ | Added missing commas between elements |
What this fixer does NOT repair
These are real JSON errors the tool leaves unchanged. After these the output is reported as Partially fixed (yellow). Use the sibling tool or manual edit noted in the last column.
| Broken input | Why it survives | What to do |
|---|---|---|
{"a": NaN} / {"a": Infinity} | No pass targets these IEEE-754 tokens | Replace with null or a number by hand |
{"a": 1 // note\n} | No comment-stripping pass exists | Delete the // and /* */ comments manually |
{“key”: 1} (smart quotes) | Only straight ' single quotes are converted, not curly “ ” | See the copy-paste repair guide below |
{"a": 01234} / {"a": 0xFF} | No numeric-literal normalization | Strip the leading zero or convert hex by hand |
{"a": 1 (missing }) | No bracket-balancing pass | Add the closing bracket manually |
my-key: 1 (hyphen in key) | Unquoted-key regex stops at -; only [A-Za-z0-9_$] keys are matched | Quote the full key by hand: "my-key": |
Cookbook
Real before/after runs. Each shows the input, the exact Fixes applied list, and the validity banner you'd see.
Trailing comma after the last property
ExampleThe classic hand-edit: you deleted the last key but left its comma. The fixer's trailing-comma pass strips it and parsing succeeds on the retry.
Input:
{
"name": "widget",
"qty": 5,
}
Fixes applied (1):
✓ Removed trailing commas
Banner: Fixed & valid JSON
Output (indent 2):
{
"name": "widget",
"qty": 5
}JavaScript object literal copied from source
ExampleBare keys plus single-quoted values plus a trailing comma — three different passes fire on one input. They run in order and the combined result parses.
Input:
{ name: 'widget', tags: 'a', }
Fixes applied (3):
✓ Replaced single quotes with double quotes
✓ Added quotes to unquoted object keys
✓ Removed trailing commas
Banner: Fixed & valid JSON
Output:
{
"name": "widget",
"tags": "a"
}undefined left over from a stringify edge case
ExampleAn object logged from a debugger printed undefined literally. The undefined pass turns the value into null. The pass is string-aware, so the word undefined inside any string value is left alone.
Input:
{ "user": "sam", "deletedAt": undefined }
Fixes applied (1):
✓ Replaced undefined with null
Banner: Fixed & valid JSON
Output:
{
"user": "sam",
"deletedAt": null
}Two objects with the comma dropped between them
ExampleConcatenated objects in an array where the separating comma was lost on a newline. The missing-comma pass inserts it where } is followed by \n{.
Input:
[
{ "id": 1 }
{ "id": 2 }
]
Fixes applied (1):
✓ Added missing commas between elements
Banner: Fixed & valid JSON
Output:
[
{ "id": 1 },
{ "id": 2 }
]Something the fixer can't repair — and says so
ExampleA missing closing brace has no pass. The fixer runs its passes, none apply, and it returns the input unchanged with a yellow banner rather than pretending it succeeded.
Input:
{ "a": 1
Fixes applied (0)
Banner: Partially fixed — output may still have issues
Output (unchanged):
{ "a": 1
Next step: open the JSON validator for the exact error position,
then add the missing } by hand.Errors and edge cases
Real errors and silent failures sourced from each platform's own documentation. Match the wording to the row, fix what the row says to fix.
undefined inside a string value is preserved
By designThe undefined → null pass is string-aware: it walks the text tracking whether it is inside a quoted string, so it only rewrites a bare undefined value. A string like "value undefined here" is left exactly as-is, while a real undefined value becomes null — e.g. {"note":"value is undefined here","v":undefined} fixes to {"note":"value is undefined here","v":null}. No post-fix review of strings is needed.
Apostrophe inside a single-quoted value
RejectThe value-quote pass matches '([^']*)' — it stops at the first inner apostrophe. A value like 'can't' matches only 'can', leaving t' dangling, and the result fails to parse. Switch the offending quotes to double quotes by hand, or wrap apostrophe-bearing values in proper double quotes at the source.
NaN, Infinity, -Infinity
InvalidThese are valid JavaScript but not JSON, and no pass targets them. The output is returned unchanged with a yellow Partially-fixed banner. Replace them with null or a finite number manually before re-running.
// or /* */ comments
InvalidJSONC-style comments are common in config files but standard JSON forbids them, and this tool has no comment-stripping pass. The file stays invalid. For commented config, keep using a JSONC parser; to ship strict JSON, delete the comments yourself first.
Smart / curly quotes
InvalidOnly straight ASCII ' single quotes are converted. Curly “ ” ‘ ’ from a word processor or chat app are left alone and break parsing. The copy-paste repair workflow in the paste-fix guide covers this scenario.
Missing or unbalanced brackets
FailThere is no bracket-balancing pass. {"a":1 (no closing brace) or an extra ] is returned as-is and reported invalid. Use the JSON validator to locate the imbalance and add or remove the bracket by hand.
Unquoted key containing a hyphen or dot
RejectThe unquoted-key pass only matches [a-zA-Z_$][a-zA-Z0-9_$]*. A key like my-key: or a.b: is not matched and the file stays invalid. Quote the full key manually.
Already-valid JSON
ExpectedIf the input parses on the first try, no passes run, the Fixes applied list is empty (No fixes needed), and the output is simply re-indented to your chosen 2 or 4 spaces. The fixer doubles as a prettifier for clean input.
File larger than 2 MB on free tier
BlockedThe free JSON limit is 2 MB (TIER_LIMITS.free.json.fileBytes). Larger files prompt an upgrade; Pro raises the ceiling to 100 MB. There is no row limit on this tool — only the byte ceiling applies.
Frequently asked questions
Exactly which errors does this fixer repair?
Five, and only five: trailing commas before }/], single-quoted keys and simple string values (converted to double quotes), unquoted identifier-style keys, the literal token undefined (converted to null), and a missing comma where } or ] sits on a line directly above the next {, [, word, or quote. Everything else is left untouched and reported as still-invalid.
Why does it say 'Partially fixed' even after running?
Because after the five passes it re-runs JSON.parse(), and if that still throws it labels the output yellow rather than green. The yellow output is best-effort text — the passes that did apply are reflected in it — but it is not guaranteed-valid JSON. Common causes: NaN/Infinity, comments, smart quotes, or a missing bracket, none of which it fixes.
Will it break my data while fixing?
No. The undefined → null pass is string-aware: it tracks string state as it walks the text, so it rewrites only a bare undefined value and leaves the word undefined inside any string value untouched. An undefined value becomes null; a string such as "value undefined here" is preserved verbatim. Valid JSON is re-serialized exactly. No review of strings is needed after a fix.
Does it fix NaN and Infinity?
No. They're valid JavaScript but not JSON, and no pass targets them. The output comes back unchanged with a yellow banner. Replace them with null or a finite number by hand, then re-run.
Does it strip // and /* */ comments?
No — there is no comment-stripping pass. Standard JSON forbids comments and this tool produces standard JSON, but it won't remove existing comments for you. Delete them manually, or if you want to keep comments use a JSONC parser instead of JSON.parse.
Does it add missing closing brackets?
No. There's no bracket-balancing logic. A truncated {"a":1 is returned as-is and reported invalid. The missing-comma pass only inserts commas between already-closed elements; it never adds } or ].
What's the difference between JSON and JSON5?
JSON5 is an unofficial superset that allows trailing commas, single quotes, unquoted keys, and comments. This fixer converts three of those JSON5 features (trailing commas, single quotes, unquoted keys) to strict JSON, but not comments. For full JSON5 support you'd need the json5 npm package; this tool targets the common cases and outputs RFC 8259 JSON.
Can I control the output formatting?
You can pick 2-space or 4-space indentation — those are the only two options in the UI. The fixer always re-serializes via JSON.stringify, so the output is consistently formatted regardless of how the input was laid out. For minified single-line output instead, use the JSON minifier.
Does it handle NDJSON or JSON Lines?
Not as a line-by-line repairer. It treats the whole input as one document. If you paste two objects on separate lines it will try to comma-join them into a single broken array, which usually still fails to parse. For genuine NDJSON repair, see the log-parsing guide for the per-line approach.
Is my JSON uploaded anywhere?
No. The file is read locally via file.text() and all five passes plus JSON.parse run in your browser. Nothing is sent to JAD Apps servers. When signed in, a single anonymous run counter (no content) is recorded for dashboard stats; you can opt out in account settings.
What file types and sizes are accepted?
Extensions .json, .ndjson, .jsonl, and .txt; MIME types application/json, application/x-ndjson, and text/plain. The free tier caps files at 2 MB; Pro raises it to 100 MB. There's no row limit on this tool.
After fixing, how do I verify the result is correct?
If the banner is green, the output passed JSON.parse, so it's syntactically valid. To confirm structure and types, run the output through the JSON validator, and to compare against the intended shape, diff it with the JSON diff tool.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.