What a JSON formatter does
JSON (JavaScript Object Notation) is the most common format for sending data between web services and storing configuration. Machines read it happily without spaces, so API responses are often a single long line that is hard for a person to read. A formatter parses the text and writes it back with consistent indentation, one item per line, which makes the structure visible. A minifier does the reverse and removes every optional space to save bytes. This page does both, and also checks that your text is valid JSON.
How validation works
The tool hands your text to the JSON parser that is built into your browser, the same one web applications use. If the text is valid, it is re-serialised with your chosen indent. If not, the parser's error message is shown together with the line and column, worked out from the character position it reports. Typical mistakes include a trailing comma after the last item, single quotes instead of double quotes, unquoted property names, comments (which JSON does not allow) and missing commas between items. Strict parsing means that what passes here will also pass in most programming languages.
Options
- Indent: two spaces is common in JavaScript projects, four in many other languages, and tabs suit editors that let you set the width.
- Sort keys: orders every object's keys alphabetically at all depths. This is helpful when comparing two JSON files, since the same data then looks the same. Array order is never changed.
- Minify: produces the compact form for embedding in code, URLs or network payloads.
Things to know
JSON numbers follow JavaScript rules, so integers larger than 9,007,199,254,740,991 lose precision when parsed. If you work with large identifiers, keep them as strings. Duplicate keys in the same object are accepted by the parser, and the last one wins, so one of them disappears from the output. Special values such as NaN, Infinity and undefined are not valid JSON.
Privacy
Everything happens locally. The text you paste is not uploaded, logged or stored, so it is reasonable to use the tool with internal data, although you should still avoid pasting live secrets into any website out of habit.