Formatting a compact object
A one-line API response needs to be readable.
- Input: {"b":2,"a":1}
- Format with two spaces
- Output: { "b": 2, "a": 1 }
The formatted version is easier to inspect. Minifying returns the original compact form without spaces.
This JSON formatter pretty-prints, minifies and validates JSON without sending it anywhere. Invalid input is reported with the line and column where parsing failed, and an optional key sort makes diffs easier to read.
Your data is processed locally in your browser and is not uploaded to our server.
JSON.stringify(value, null, indentation)
Formatting parses the JSON into a value and re-serialises it with the chosen indentation. Minifying uses the same serialisation without indentation or extra whitespace.
Invalid JSON → position, then line and column
When parsing fails, the parser position is converted into a line and column number. The browser or runtime message is shown after a short localized prefix.
A one-line API response needs to be readable.
The formatted version is easier to inspect. Minifying returns the original compact form without spaces.
A trailing comma breaks a configuration file.
The line and column numbers point to the first place where the parser could not continue.
Comments, trailing commas, single quotes and undefined are not valid JSON. Use a strict JSON linter if the file is JSON5 or JSONC.
Formatting happens locally, but very large documents can take a moment. Browser memory limits apply; split huge files into smaller parts.
JSON objects are unordered by specification. Enabling key sorting produces a deterministic output, which is useful for comparing files.
No. It reports the problem instead of guessing. Fix the reported line or column and format again.
Formatting adds indentation and line breaks for readability; minifying removes optional whitespace to make the payload smaller. Both preserve the same data.
Yes. Enable “Sort keys” and the formatter sorts object keys alphabetically at every nesting level. Array order is never changed.
No. Parsing and formatting run in your browser; the data is not sent to a server or stored.
JavaScript object syntax allows comments, trailing commas and single quotes, which JSON does not. Remove those features or use a JSON5 tool.