How it works
The tool reads your text with the same JSON parser your browser uses. If the text is valid it is written back out with the indentation you choose, or with all spaces removed if you pick minify. If it is not valid, you get the engine's message and, where it gives a position, the line and column so you can find the problem.
Sorting keys puts every object's keys in alphabetical order, which makes two JSON files easier to compare. Arrays keep their order, because the order of an array is part of its meaning.
Everything runs on your device. Your JSON is not uploaded, so it is fine to paste data that you would not want to send to a stranger's server, though you should still avoid pasting live passwords or keys anywhere.
Check it by hand: count the keys in {"name":"Ivory","tools":[{"id":1,"free":true},{"id":2,"free":true}],"note":null}. They are name, tools, id, free, id, free and note, so 7 keys. The nesting is the main object, then the tools array, then each object inside it, so the depth is 3. Formatting only adds line breaks and spaces, so the data stays the same while the text grows from 80 to 148 characters.
Worked example
The text {"a":1,"b":[true,null]} becomes a readable block with each key on its own line when formatted with 2 spaces, and stays on one line when minified.
The text {"a":1,} is not valid JSON because of the trailing comma. The tool reports the position of the closing brace.
Good to know
- JSON has no comments, single quotes or trailing commas. Text that looks like JSON from a JavaScript file often has them, and will be reported as invalid.
- Very large whole numbers (more than about 15 digits) lose precision when parsed, as in any JavaScript tool. If exact digits matter, keep them as strings.
- Duplicate keys in one object are merged and only the last value is kept.
Questions people ask
How do I format JSON?
Paste it into the box and choose Format. The result appears indented and ready to copy.
Why does it say my JSON is invalid?
The most common causes are a trailing comma, single quotes instead of double quotes, unquoted keys, or a missing bracket. The message shows the line and column where the parser gave up.
What does minify do?
It removes all the spaces and line breaks that are not needed, so the file is as small as possible. The data does not change.
Is my JSON uploaded?
No. It is parsed in your browser and never sent to a server.
Does sorting keys change the meaning?
No. The order of keys in an object has no meaning in JSON. Array order is kept as it is.
What is the difference between formatting and minifying JSON?
Formatting adds line breaks and indents so people can read it, and minifying removes them so the text is smaller. The data is the same either way. {"a": 1, "b": [1, 2]} minified is {"a":1,"b":[1,2]}.
Part of the guide: Developer and design tools: QR codes, passwords, JSON, colors and timestamps