JSON Formatter
Make unreadable JSON readable, and find what broke it.
About this converter
Indents JSON so you can read it, and tells you where it is broken when it is.
The error message is the point. A browser reports a bad document as "Unexpected token } in JSON at position 482", which is accurate and useless when the input is one long line. Here the offset is turned into a line and column you can actually navigate to, along with what the parser expected.
Sorting keys is off by default and worth turning on for one specific job: comparing two API responses that should match. Objects have no defined key order, so the same data can serialise differently on two runs and a naive diff lights up everywhere. Sorting both first makes the real differences visible. Array order is left alone, because arrays do carry meaning in their order and sorting them would change the data.
The count under the result — keys and nesting depth — is there because "is this the shape I expected" is usually the actual question.
Frequently asked questions
Why is my JSON invalid when it looks fine?
The four usual culprits: a trailing comma after the last item, single quotes instead of double, unquoted keys, or a comment. All four are legal in JavaScript and none are legal in JSON. JSON5 and JSONC allow some of them, but the standard parsers your code will use do not.
Does formatting change my data?
No. It is parsed and re-serialised, so whitespace changes and nothing else — unless you turn on key sorting, which reorders object keys. That is safe, because JSON objects have no defined order, but it does make the output differ from the input byte for byte.
Why does it not sort arrays?
Because that would change the data. The order of an array is part of its meaning — a list of steps, a ranked result set, a sequence of events. Object keys have no such guarantee, which is why sorting those is safe and sorting arrays is not.
Will very large files work?
Up to a point. Everything happens in your browser tab, so the limit is the memory of the machine you are on rather than an upload cap. A few megabytes is comfortable; a hundred-megabyte log will not be.
Does what I paste get sent anywhere?
No. The conversion runs in your browser, on your own machine — that is why the result appears as you type rather than after a wait. Nothing is uploaded, nothing is logged, and closing the tab is the end of it. This matters more here than on most pages: tokens, keys and internal data get pasted into tools like this constantly, and most of them are a form that posts to a server.