What this validator checks
JSON (JavaScript Object Notation) is the text format almost every web API uses to send data. It is strict: a single misplaced comma makes the whole document unreadable to a parser, and the error you get back is often a vague “Unexpected token”.
This tool parses your input against the JSON standard (RFC 8259, also published as ECMA-404). If it parses, you get it back either prettified — one value per line with 4-space indentation — or minified to a single line with no extra whitespace. If it does not parse, you get the parser’s error message. Anything that passes here will also be accepted by JSON.parse() in JavaScript, json.loads() in Python, and json_decode() in PHP.
The errors you will actually hit
JSON looks like a JavaScript object, but it is much stricter. Nearly every “Syntax error” comes from one of these:
- Trailing comma.
{"a": 1, "b": 2,}is invalid. Delete the comma after the last item in every object and array. - Single quotes.
{'name': 'Ann'}is invalid. Keys and strings must use double quotes. - Unquoted keys.
{name: "Ann"}is valid JavaScript but invalid JSON. Write{"name": "Ann"}. - Comments.
//and/* */are not allowed. Config files such as VS Code’s settings use a looser format called JSONC that does allow them; strip the comments before validating here. - JavaScript-only values.
undefined,NaN,Infinityand functions do not exist in JSON. Usenull, or a string, instead. - Raw line breaks or tabs inside a string. These must be escaped as
\nand\t. This often happens when text is pasted from a document.
The error message does not give a line number, so for a long document the quickest way to find the problem is to halve it: delete the second half of an array or object, validate, and repeat on whichever half still fails.
Prettify or minify?
Prettify
Puts each value on its own line with 4-space indentation. Use it when reading an API response, reviewing a config change, or pasting JSON into documentation.
Minify
Removes every space and line break that is not inside a string. Use it when the JSON is going into an environment variable, a single-line log entry, or a request body where size matters.
How much minifying saves depends on how the JSON was formatted to begin with. A deeply nested file indented with spaces can shrink by a quarter or more; one that was already compact barely changes. If the JSON is served over HTTP with gzip or Brotli compression, most of that whitespace saving is already captured by the compression.
Questions
Will formatting change my data?
No values change, but a few representation details may. Escaped characters such as é are written out as the character itself (é), and escaped forward slashes (\/) become plain slashes. Both forms mean exactly the same thing to any JSON parser. If the same key appears twice in one object, only the last value is kept, which is also what most parsers do.
Why did a very long number change?
Integers larger than about 9.2 quintillion, and decimals with more than about 15 significant digits, cannot be stored exactly as numbers and are rounded. JavaScript has the same limit (above 9,007,199,254,740,991). If you need IDs that long to survive, send them as strings.
Is there a size limit?
Nesting is limited to 512 levels. For files of several megabytes, a local editor or a command-line tool such as jq will be faster than any web page.
Working with SQL too?
The SQL formatter tidies up long queries into readable, indented form.