A JSON formatter turns compact or messy JSON into indented, readable text, and a JSON validator tells you whether text is valid JSON and where it breaks. This tool does both, plus minifying. It runs with your browser's built-in JSON.parse and JSON.stringify; nothing you paste is sent to PagesTest.
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'x'} | {"a": "x"} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Remove the comment; JSON has no comments |
| JavaScript-only values | undefined, NaN, Infinity | null or a number |
| Raw line break inside a string | A string split over two lines | Use \n inside the string |
An error at position 0 or 1 often means the text isn't JSON at all, for example an HTML error page returned by an API instead of the response you expected.
Formatting only changes whitespace, with three exceptions that come from how browsers parse JSON:
12345678901234567890 becomes 12345678901234567000. Keep such values as strings, or don't use the formatted output for them.1.50 becomes 1.5 and é becomes é. The values are the same; only their spelling changes.No. Formatting, minifying and validating all happen in your browser, so the tool is safe to use with API responses that contain private data.
The parser found a character it didn't expect at that position, most often a trailing comma, a single quote, an unquoted key, or the start of an HTML page where JSON was expected.
Formatting adds line breaks and indentation so people can read it. Minifying removes all unnecessary whitespace so the JSON is as small as possible to send or store. Both describe exactly the same data.
No. Standard JSON has no comment syntax. Some tools accept variants such as JSONC or JSON5 that allow comments, but this validator, like JSON.parse, follows the standard.