JSON Formatter and Validator: Find the Error, Then Pretty-Print
By FindMySum · Last reviewed
This JSON formatter checks your JSON against the standard, points to the exact line and column of the first mistake, and then pretty-prints or minifies it. Paste an API response, a configuration file or a log line into the box above; it works in your browser as you type, and nothing you paste leaves your device.
What it checks
JSON has a small grammar and very little tolerance. A document is one value: an object in braces, an array in brackets, a string in double quotes, a number, or one of the words true, false and null. Keys must be strings in double quotes. Numbers can't have leading zeros, a plus sign, or the values NaN and Infinity. Strings can't contain a raw line break or tab. The formatter reports each of these with a plain-language message instead of "unexpected token".
It also flags two things that are valid but risky: duplicate keys, listed with their paths, and numbers too long for JavaScript, such as 19-digit order IDs that most programs would round.
How to use it
- Paste or type your JSON. The result updates as you type.
- If there is an error, read the message under the output and press "Show it in the input" to jump to the spot.
- Choose Format for readable output with 2 spaces, 4 spaces or tabs, or Minify to remove every unneeded space before sending or storing it.
- Turn on Sort keys to make two documents easy to compare, or JSONC for files that contain comments.
- Copy or download the result.
A worked example
Take {"name":"Ada","langs":["en","fr",],"id":01}. The formatter stops at the comma before ] (line 1, column 33): strict JSON doesn't allow a trailing comma. Remove it and it stops again at 01, because JSON numbers can't start with a zero; an ID like that should be the string "01". With both fixed, formatting gives:
{
"name": "Ada",
"langs": [
"en",
"fr"
],
"id": "01"
}
Common mistakes
Copying JavaScript instead of JSON. Object literals in code often have unquoted keys, single quotes and trailing commas. They look like JSON but aren't.
Smart quotes and invisible spaces. Text copied from a word processor or a chat app can contain curly quotes or no-break spaces. The error names the character, even when you can't see it.
Concatenated documents. Log files often hold one JSON object per line (JSON Lines). That is many documents, not one, so the formatter stops after the first. Wrap them in an array, or check one line at a time.
When you need the data in another shape, related tools convert between formats, and the Base64 decoder unpacks JSON that arrives Base64-encoded, as in a token or a data URL.