fix invalid json

runs in your browser, nothing is uploaded

IDLE

stdin

stdout

Made by Maiyarasu S

Paste JSON that will not parse and see exactly what is wrong, with a list of repairs you can review before applying them. Nothing is uploaded: the repair runs in your browser.

What auto-fix can repair

Comments, trailing commas, missing commas between items, single quotes and curly “smart” quotes, unquoted keys, and the words NaN, Infinity, undefined, None, True and False, which become null, true or false. Hex numbers and spellings such as .5, 5. or +1 become plain JSON numbers.

It also unwraps the forms JSON often arrives in: a markdown code fence copied from a chat or a README, with or without text around it, and JSONP callbacks such as callback({...}). Input that was cut off is closed where it ends.

How the repair works

The page parses strictly first and reports the first error with its line, column and a caret. If the input can be repaired, it lists the changes with their positions (the first 200, with a count of the rest), and clicking a change jumps to it. Nothing changes until you press apply.

Applying rewrites the input as strict JSON, and undo brings back your original. When a document cannot be repaired safely, for example when a colon is missing between a key and its value, the error stays and points at the spot to fix by hand.

Questions

Will it guess missing data?

Only at the end of cut-off input. A value that was cut off is written as null, a key cut off before its value is dropped, and unfinished objects and arrays are closed. A value missing in the middle of a document is an error, not something it fills in.

Does it keep my comments?

No. JSON has no comments, so they are removed. Undo restores your original if you need them.

Can it repair JSON Lines?

Yes. Documents on separate lines are repaired one by one and written back one per line.

Is the broken JSON uploaded?

No. Parsing and repair both run in this page.

Related tools

help

QUERY (the prompt line)

Type a path or a filter after guest@json:~$. JSONPath and a jq-style subset both work, and the output shows only the result. Convert, copy and save then apply to that result.

$.users[0].nameone value by path. .users[0].name is the same thing
$["odd key"] $.ports[-1] $.ports[1:3]quoted keys, counting from the end, slices
$.users[*].name or .users[].nameevery item
$..namethat key at any depth
$.users[?(@.id > 1001 && @.sudo)]filter. Operators: == != < <= > >= && || !
.users[] | select(.sudo) | .namethe same idea in jq style, with pipes
.users | map(.name) | sortbuild a new list
[.users[] | select(.sudo)] | lengthcollect matches into an array, then count

Functions: length, keys, keys_unsorted, values, type, first, last, sort, sort_by(f), unique, reverse, flatten, add, min, max, to_entries, not, select(f), map(f), has(k), test(regex), contains(x), startswith(s), endswith(s).

TABS A AND B

stdin has two tabs. diff compares a with b by structure: key order is ignored, and an item inserted into an array counts once. validate checks tab a against the JSON Schema in tab b. Click any row in either list to open that spot in the tree.

REPAIR

When input is not valid JSON, the error view lists what auto-fix would change, line by line, before you apply it: comments, trailing or missing commas, single or smart quotes, bare keys, NaN and Infinity, hex and other number spellings, markdown code fences, JSONP wrappers, and input that was cut off. undo brings your original back.

VALUE HINTS

Links are clickable. Numbers that look like Unix times show the date. A badge after a string means it holds something: {…} JSON, jwt a token (decoded, never verified), b64 base64 text. Click the badge, or press Enter on the row, to expand it in place. A token pasted on its own, with or without Bearer in front, is offered as decode jwt instead of a parse error. Decoding never checks the signature.

KEYS

Ctrl+F or /search the output: the tree, or the text of minify, yaml, csv and ts. Enter next match, Shift+Enter previous. Write /pattern/ for a regular expression. In text output the keys and values buttons are off, and diff and validate switch to the tree
Alt+Qgo to the query prompt. Esc clears it
↑ ↓ ← →move in the tree. Left and right fold and unfold, with Shift they do the whole branch
Enter / Ctrl+C in the treefold or expand the row / copy the selected value
Ctrl+Enterformat stdin in place
Ctrl+Ssave the output as a file
Alt+C Alt+M Alt+S Alt+Fcopy, pretty or minify, sort keys, fold
Alt+1 Alt+2 Alt+Ttab a, tab b, next theme
Tab / Shift+Tab in stdinindent and outdent. Press Esc first to tab out of the box instead
Ctrl+Z / Ctrl+Shift+Z in stdinalso undo and redo format, auto-fix, load and clear

On a Mac, use Cmd for Ctrl and Option for Alt.

SAVED INPUT AND DISPLAY

Both tabs are kept in this browser between visits, however large. If the browser cannot keep an input, a note says so. The crt button turns scanlines and glow off. The page also drops them, and brightens dim text and borders, when your system asks for more contrast.

PRIVACY

Everything runs in this page, and the fonts are served with it. Nothing you paste is sent anywhere. A share link holds the compressed input inside the link itself, so anyone you send the link to can read it.

What you paste is also saved in this browser, so it is still here on your next visit. On a shared computer, or after pasting a secret, clear it. This removes both tabs and your settings from this browser.