JSON Formatter and Minifier

Indent JSON so you can read it, or strip the whitespace to get one line. When the JSON is invalid you get the line, the column, and the offending line itself — telling someone that a 4,000-line file is broken somewhere is no help at all.

Indent

Pasted code never leaves your device. Everything runs in your browser; nothing is sent or stored anywhere. That is what makes it usable for internal config files and production queries.

JSON is not a JavaScript object

The two look alike, so habits from JavaScript carry over. Keys must be wrapped in double quotes, and single quotes are not allowed even around strings. A comma after the last item, // comments, undefined and NaN are all outside the standard. This checker does not lump those mistakes together as an unexpected character — it says whether it was a single quote, a trailing comma, or an unquoted key, because you cannot fix what you cannot name.

The position is found by scanning the text ourselves

The browser's JSON.parse only refuses; it does not report a reliable position. So when it refuses, a small scanner walks the text from the start, finds the exact character where things went wrong, converts that to a line and column, and shows the line with a caret under it. Things you cannot spot by eye are caught here too: a raw line break inside a string, a \u escape without four hex digits, nesting deeper than 500 levels.

Values survive, but their spelling may change

The text is parsed once and written back out, so meaning is preserved. Numbers, however, become JavaScript numbers: 1.0 comes out as 1 and 1e3 as 1000. Integers beyond 2^53 — snowflake IDs, 64-bit keys — silently lose their last digits, which is why such values should be stored as strings. Escapes like \u00e9 are resolved into the real character, and when a key appears twice only the last one remains. Sizes are counted in UTF-8 bytes, so one Korean or Japanese character is three bytes.

The invisible character that fails at line 1, column 1

A byte-order mark at the head of a file is a character, not whitespace, so it fails at line 1, column 1 — with the caret pointing at nothing visible. Files saved by Windows Notepad are the usual source. JSON Lines, one object per line, is not one document and fails at the start of line 2 — paste one line at a time, or wrap the lot in [ ] with commas. The other way round, a lone "text" or 123 is valid JSON by the standard and passes.

The formatted shape, and long results

Indentation is two spaces or four. An empty array or object stays on one line as [] or {}, but once it holds anything, every element takes a line of its own — ten thousand numbers become ten thousand lines. Past 4,000 lines the line numbers are folded away and the text is drawn as one block, unchanged. You can also send the result back up into the input and minify it.

Frequently asked questions

Does it tell me exactly where the error is?

Yes. Browser parser messages are not dependable — Chrome drops the position entirely on short input and quotes a fragment instead, and the wording differs between browsers. So the input is scanned here to find the exact character offset where it broke, then converted to a line and column. Common mistakes such as single quotes or a trailing comma come with an explanation of what went wrong.

Will my key order change?

No. Keys are written back in the order they appeared. Note that key order carries no meaning in the JSON standard, so if you have code that depends on it, that code is the safer thing to fix.

Does it accept JSON with comments?

Standard JSON has no comments. Files that allow them, like tsconfig.json, will fail at that point — strip the comments first.

Can it handle very large files?

Everything runs in this device's memory, so tens of megabytes will strain the browser. For files that size, paste only the part you need.

The result has no line numbers.

Past 4,000 lines the numbers are folded away — each line is its own element, and tens of thousands would weigh the browser down. The text is all there and copies fine. If you need the numbers, paste it into an editor.

Does anything I paste get sent to a server?

No. Everything runs inside your browser and nothing is uploaded or stored. That is why you can use it on things you would not normally paste into a web page, like an internal config file or a production query. It also works with your network disconnected.