JSON Formatter and Validator
A formatter has one job and one way to fail it: changing the data while tidying the layout. A dropped key, a reordered array, a number that comes out slightly different — none of these show up by looking, because the output is valid JSON either way. So the result here is parsed again and compared against the original, value by value, all the way down.
What this generator does
Parses your JSON, writes it out in the layout you choose, optionally sorting every object's keys, and reports the shape of the document alongside.
How to use this tool
- Paste your JSON, minified or indented — either works.
- Choose how you want it laid out.
- Tick the box to sort every object's keys.
- If it will not parse, the line and column are given with the text around them.
Understanding the controls
- Your JSON
- Up to four hundred thousand characters, in any layout. What matters is that it parses.
- Style
- Two spaces, four spaces, tabs, or minified with no spaces at all.
- Sort the keys
- Sorts every object's keys alphabetically at every level. Arrays keep their order, since the order of an array is part of its meaning.
Common use cases
- Making a minified API response readable
- Minifying a configuration file before shipping it
- Finding where an invalid document actually breaks
- Sorting keys so two documents can be compared
- Checking the shape of an unfamiliar payload
How this generator works
The formatted text is parsed again and compared against the parsed input value by value — a comparison that does not care how the text was rearranged, only that it still says the same thing. The output is also formatted a second time to confirm it is settled, and where keys were sorted, every object is checked to be in order at every level.
Randomness and fairness
Nothing is random. The same document and settings always produce the same output.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Strict JSON: comments, trailing commas and single quotes are not accepted, because they are not JSON.
- Duplicate keys in the input are resolved the way every JSON parser resolves them — the last one wins — and the check compares what was parsed rather than the raw text.
- Very large numbers are held as the language holds them, so a number beyond that precision may come back slightly different, and the comparison would report it.
- Four hundred thousand characters at most.
Privacy and your data
Your JSON stays in your browser. Nothing you paste is transmitted or stored.
Related generators
- Markdown Table GeneratorTurns pasted rows into a tidy Markdown, HTML, plain-text or CSV table, and reads the result back to prove nothing was mangled.
- JSON Sample GeneratorGenerate a small sample JSON object with randomised placeholder values, for API mockups.
- List CleanerRemoves duplicates, sorts and counts a pasted list, with every line traced back to the one you pasted.
- YAML Sample GeneratorA small sample YAML fixture, distinct from the site's JSON-sample tool.