JSON is everywhere — API responses, config files, database exports, web hooks. But raw JSON is often minified into one unreadable line. Here is how to format it properly and fix common errors.
What Is JSON?
JSON (JavaScript Object Notation) is a lightweight data format used to exchange information between servers and clients. It consists of key-value pairs, arrays, and nested objects. A simple JSON object looks like:
{"name":"John","age":30,"city":"London"}
How to Format JSON (Pretty Print)
Formatted (pretty-printed) JSON adds indentation and line breaks to make it readable:
{
"name": "John",
"age": 30,
"city": "London"
}
Use Anonymiz JSON Formatter — paste any JSON and get it instantly formatted, validated, and colour-coded. Free, runs in your browser, nothing sent to any server.
Common JSON Errors and How to Fix Them
- Unexpected token — Usually a missing comma, unclosed bracket, or trailing comma after the last item. JSON does not allow trailing commas:
{"a":1,"b":2,}is invalid. - Unexpected string — Keys must be in double quotes. Single quotes are not valid JSON:
{'name':'John'}is invalid. Use{"name":"John"}. - Unexpected end of JSON input — A bracket or brace was opened but never closed. Check that every
{has a matching}and every[has a matching]. - Expected colon — Missing the colon between a key and its value.
JSON Validation Rules
- All strings must use double quotes.
- Keys must be strings in double quotes.
- No trailing commas after the last item in an object or array.
- No comments — JSON does not support
//or/* */comments. - Numbers must not have leading zeros:
01is invalid,1is correct.
JSON vs JSON5 vs JSONC
JSON5 and JSONC (JSON with Comments) are supersets of JSON that allow single quotes, trailing commas, and comments. They are used in config files like tsconfig.json and VS Code settings but are NOT valid standard JSON.


