Format, minify or validate
JSON returned by an API or stored in a log is often a single long line that is hard to read. Format parses the text and prints it with consistent indentation: 2 spaces, 4 spaces or tabs. Minify does the opposite and removes every unnecessary space and line break, which makes the data smaller for storage or for sending in a request. Validate only checks the syntax and reports how many keys the document contains and how deeply it is nested.
Tick “Sort keys alphabetically” to order the keys of every object, which makes two versions of a file much easier to compare. Arrays keep their order, because in JSON the order of array items matters.
Finding errors
If the input is not valid JSON, the message shows the line and column where the parser stopped. The most common mistakes are:
- a trailing comma after the last item of an object or array
- single quotes instead of double quotes around strings or keys
- keys without quotes, as in JavaScript objects
- comments, which standard JSON does not allow
- special values such as
NaN,undefinedorInfinity
The error is usually at the reported position or just before it, for example a missing comma at the end of the previous line.
Privacy
Developers often paste tokens, customer data or configuration into online formatters. This one runs entirely in your browser with the built-in JSON parser: nothing is uploaded or logged, and the page keeps working offline. Large files of several megabytes are handled as fast as your device allows.
Need YAML instead? Use the JSON to YAML and YAML to JSON converters on this site.
A worked example
Suppose an API returns a single line like {"id":42,"tags":["a","b"],"owner":{"name":"Ana","active":true}}. Formatting it with two-space indentation puts each key on its own line and nests the owner object below, so you can see the structure at a glance. If you then delete the closing brace by accident and validate, the tool reports a parse error near the end of the text, which points you straight to the missing character. Minifying the corrected text turns it back into one compact line, ready to paste into a configuration field or a request body.
Common JSON mistakes
Most invalid JSON comes from a handful of habits carried over from JavaScript or other formats:
- trailing commas after the last item in an object or array;
- single quotes instead of double quotes around strings and keys;
- keys without quotes at all;
- comments, which standard JSON does not allow;
- special values such as NaN, Infinity or undefined;
- unescaped line breaks or quotes inside a string.
Fixing these by hand is quick once the validator points to the line.
Formatting in your workflow
Formatted JSON is easier to review in code changes, because each value sits on its own line and a diff shows exactly what changed. Sorting keys alphabetically makes two versions of the same object easier to compare, although it is best avoided where key order carries meaning for humans, such as a hand-written configuration file. For large production payloads, minified JSON saves bandwidth, but compression on the server usually reduces the difference to a few percent.