JSON Formatter Guide: Reading, Validating, and Debugging JSON Like a Professional
JSON is the lingua franca of modern web APIs — every config file, every fetch response, every webhook payload. A formatter is one of the most-used tools in any developer's daily workflow. This guide explains what JSON is, the rules that trip people up, and how to debug the errors you'll actually run into.
JSON (JavaScript Object Notation) was specified by Douglas Crockford in 2001 as a lightweight alternative to XML. It is intentionally minimal — six data types, two structural characters, no comments, no schema. That minimalism is exactly why it took over: there is so little to disagree about that every programming language can implement a parser in a few hundred lines.
Despite being technically trivial, JSON has rules that surprise even experienced developers. Trailing commas are forbidden. Property names must be double-quoted. Numbers cannot start with a leading zero. There are no comments. A formatter is the fastest way to spot these mistakes — paste in suspicious JSON, format it, and any error message will pinpoint the exact character.
The six JSON data types
- string
- Sequence of Unicode characters in double quotes. Special characters are escaped with backslashes: \" for a double quote, \\ for a backslash, \n for newline, \u00A0 for arbitrary code points.
- number
- Integer or floating point. Standard mathematical notation, optional minus sign and exponent. No leading zeros, no NaN, no Infinity, no hex.
- boolean
- Lowercase true or false. Capitalized variants like True or TRUE are not valid JSON.
- null
- Lowercase null. Represents the absence of a value.
- array
- Ordered list in square brackets, comma-separated. Values can be of mixed types. Trailing commas are not allowed.
- object
- Unordered set of key-value pairs in curly braces. Keys must be strings in double quotes. {"name": "ada"}, never {name: "ada"}.
Common JSON parse errors and fixes
| Error | Likely cause | Fix |
|---|---|---|
| Unexpected token } in JSON | Trailing comma after the last array element or object property. | Remove the comma. |
| Unexpected token a in JSON | Property name missing double quotes. | Wrap the key in double quotes: "name", not name. |
| Unexpected end of JSON input | Truncated payload — the closing bracket or quote is missing. | Check for cut-off content; the API response may have been truncated. |
| Unexpected token ' in JSON | Single quotes used for strings. | Replace single quotes with double quotes. |
| Unexpected number | Leading zero, hex notation, or NaN/Infinity. | Remove leading zero, convert hex to decimal, replace NaN with null. |
| Bad escaped character | Backslash followed by an unsupported letter. | Allowed escapes: \" \\ \/ \b \f \n \r \t \uXXXX. Anything else needs the backslash doubled. |
Pretty-printing vs minifying
Pretty-printed JSON uses indentation and line breaks so a human can read it. Minified JSON strips every optional space, which makes the payload smaller — usually 20–60% smaller — for transmission. Both versions parse to exactly the same data structure, so the choice is about audience: minified for the wire, pretty-printed for debugging and configuration files.
A typical workflow: format API responses while debugging in the browser console, then store and transmit as minified for production. Most build tools handle the minification automatically.
Things that look like JSON but are not
- •JSON5 — a superset that allows comments, single quotes, trailing commas, and hex numbers. Convenient for config files but not interoperable with strict JSON parsers.
- •JSONC — JSON with comments. Used internally by VS Code and TypeScript. Standard JSON parsers will reject it.
- •JavaScript object literals — looks similar but uses unquoted keys, allows trailing commas, supports undefined and functions. Cannot be sent to a JSON parser without reformatting.
- •YAML — a different format with similar shape that supports comments, multi-line strings, and references. Indentation-sensitive.
- •JSONL / NDJSON — one JSON object per line, separated by newlines. The whole file is not valid JSON, but each line is. Common for log streams.
Debugging a malformed payload
- 1
Paste the entire payload into the formatter
Don't trim it first — the error might be at a position the trimming hides. Most formatters will jump to the offending character.
- 2
Check the error message for line and column
Modern parsers tell you exactly where the parse failed. Open the payload in an editor with line numbers and navigate to the position.
- 3
Look one character before the reported position
Many JSON errors are reported at the character after the actual mistake — for example, the closing bracket reports the error, but the real problem is the trailing comma just before it.
- 4
Validate the surrounding structure
Bracket and brace mismatches cascade. If the error is near the end of a long payload, the actual mistake might be a missing closing bracket much earlier. Use the formatter's collapse/expand to find unbalanced sections.
- 5
If the payload looks valid, check the source
Some servers send JSON wrapped in HTML error pages, prefixed with security guards like )]}', or with a UTF-8 byte-order mark. All three confuse parsers. Strip the wrapper and try again.
Extended FAQ
Is JSON case-sensitive?
Yes — for the literals true, false, null, and for property names. The strings True or NULL are invalid. Property names that differ only in case are different keys: {"id": 1, "ID": 2} is two distinct entries.
Why doesn't JSON support comments?
By design. Crockford left them out specifically to prevent people from embedding parsing directives in comments — which had become a problem with XML. If you need comments, use JSON5 or a sibling 'comment' field that the parser will simply ignore.
How do I represent dates in JSON?
JSON has no date type. The convention is a string in ISO 8601 format: "2026-05-07T14:30:00Z". Both ends of the wire need to agree to parse it back into a date object.
What is the maximum size of a JSON document?
There is no theoretical limit, but every parser has a practical one. Browsers handle hundreds of megabytes; mobile devices typically choke past 10–20 MB. For very large data, prefer streaming formats like JSONL.
Is the JSON I paste here sent anywhere?
No. EllyTools' formatter parses and reformats everything in your browser. The payload is never uploaded, logged, or stored.
