What valid JSON is
JSON (JavaScript Object Notation, RFC 8259) is a text format with a few strict rules. A document is exactly one value: an object such as {"name": "Anna"}, an array such as [1, 2, 3], a string, a number, or one of the words true, false and null. Objects and arrays can be nested as deeply as you like.
- Strings and keys always use double quotes. Special characters are written with a backslash (
\n,\",\\,\u00e4); a raw line break inside a string is forbidden. - Entries are separated by commas, with none after the last one. A colon separates key and value.
- Numbers are decimal, without a leading zero, without a leading
+, withoutNaNandInfinity; fractions and exponents are fine (-1.5e3). - Comments do not exist. Only space, tab and line breaks count as whitespace. The encoding is UTF-8, preferably without a BOM.
The formatter above turns one long line into readable text (2 or 4 spaces, or a tab), minifies JSON for transfer and, if you like, sorts all keys recursively by character value (uppercase before lowercase). Arrays keep their order, because it carries meaning. Numbers and strings are printed exactly as you wrote them.
The most common mistakes
- Trailing comma:
{"a": 1,}or[1, 2,]. Allowed in JavaScript, not in JSON. - Single quotes:
{'a': 'b'}. They must be double quotes, strings included. - Unquoted keys:
{a: 1}. That is how a JavaScript or Python object looks when printed to a console, but it is not JSON. - Comments with
//or/* */. Configuration files in the JSONC format allow them, ordinary JSON parsers do not. - NaN, undefined, Infinity and the Python values
True,False,None. JSON only knowstrue,falseandnull. - A missing comma between two entries, often after pasting or deleting a line. The message shows where the parser stumbles; the cause is usually right before that spot.
- A line break or tab inside a string: it has to be written as
\nor\t. - BOM: an invisible character at the start of a file that some editors (mostly on Windows) save along with the text.
For the first four mistakes Try to repair can help. It removes comments and extra commas, turns single quotes into double quotes and puts keys in quotes, and it lists every change. Anything else, such as a missing comma, is for you to decide: the tool would otherwise be guessing at your data.
JSON is not a JavaScript object, and big numbers
JSON looks like a JavaScript object literal but is only a strict subset of it. An object in code may contain unquoted keys, single quotes, comments and a trailing comma, plus undefined, functions and NaN. JSON.stringify drops undefined and functions in objects, turns NaN and Infinity into null, writes a Date as a string and throws on a BigInt. So an object copied from a console is not JSON yet.
Big numbers: JSON itself sets no limit, but JavaScript reads every number as a 64-bit floating-point value. Integers are exact only up to 253 − 1 = 9007199254740991. Beyond that they are rounded: 9007199254740993 becomes 9007199254740992, with no error. This mostly hits 64-bit IDs (Snowflake IDs, for example), large counters and nanosecond timestamps. The tool warns when it finds such numbers in your text and leaves them untouched when formatting. If other programs read the JSON, send such values as strings ("id": "9007199254740993").
One more detail: duplicate keys in an object are formally allowed but unreliable, because JSON.parse keeps only the last value. The tool points them out.
Questions and answers
Is my JSON uploaded? No. Everything runs in your browser, loading a file included; there is no network request and nothing is stored.
Why does the error point somewhere other than I expected? The parser reports the spot where it notices that something is wrong. With a missing comma or bracket the cause is often a line further up. Check the line before it too.
Why do 1.0 or 1e3 stay as they are when I format? Because the tool does not rewrite numbers. That way no precision is lost, not even for very large values.
Can I check JSON with comments (JSONC) or JSON5? They do not count as valid JSON. “Try to repair” removes comments and trailing commas; JSON5 and its other extensions are only partly covered.
What about files with one object per line (JSON Lines, NDJSON)? Those are several documents. Check each line separately, otherwise the tool reports more text after the end.
How large can the JSON be? A loaded file may be 5 MB at most; you can paste more into the text box, but the browser gets slow.
Privacy
Runs entirely in your browser; nothing is sent or stored.