Text tool
JSON formatter
Format it, shrink it, or find out exactly where it is broken — line and column, not just "unexpected token".
Finding the actual problem
"Unexpected token } in JSON at position 4,721" is technically an answer and practically useless. This page converts that position into a line and a column, which is where your editor's cursor goes.
The three faults behind most broken JSON, in order of how often they turn up:
- A trailing comma.
{"a": 1, "b": 2,}. JavaScript allows it, JSON does not, and every language's JSON parser will refuse it. - Single quotes. JSON strings are double-quoted. Always.
{'a': 1}is not JSON. - Unquoted keys.
{a: 1}is a JavaScript object literal, not JSON.
Two more that are harder to spot: a real newline inside a string, which must be written \n; and a smart quote, which arrives when JSON has been through a word processor or a chat app and looks identical to the correct character.
Formatting and minifying
Format indents the structure so you can read it. Two spaces is the common default; four suits deeply nested data; tabs suit whoever has to read it in an editor set up for tabs.
Minify removes every optional space and newline. The result is identical data. This is what belongs in a request body or a configuration file that a machine reads — the panel shows how many bytes it saved, which for a large API payload is usually 20-40%.
Sort keys reorders every object alphabetically, all the way down. Key order carries no meaning in JSON, so this changes nothing about the data — but two files sorted the same way can be compared line by line, which is how you find the one setting that differs between two configurations. Sort both, then put them into the text diff.
What this tool does not do
It does not repair broken JSON. Guessing what somebody meant is how you silently change data. It tells you where the fault is and leaves the fix to you.
It does not handle JSON Lines or NDJSON — one object per line, no wrapping array. That is a different format and it will not parse here.
It does not preserve very large numbers. JSON has no integer type; the browser parses numbers as doubles, so an ID above about 9 quadrillion loses precision on the way through. If your data has 64-bit IDs, they should have been strings, and formatting them here will change them. This is a property of JSON itself, not of this tool, but it is worth knowing before you paste a database export in.
Privacy, which is the reason to use this one rather than a random site
API responses are exactly the kind of thing people paste into the first formatter a search turns up, and they routinely contain access tokens, customer records, internal hostnames and email addresses. Most online formatters send that to a server.
This one cannot. The parsing is JSON.parse in your own browser, there is no request, and there is no endpoint on our server that accepts JSON from this page. Disconnect from the network and the tool still works, which is the easiest way to check that a claim like this one is true.