How to Format and Validate JSON
JSON is a text format for storing data. Formatting makes it easy to read, and validating finds the mistakes that break it.
On this page 1 min read
What JSON looks like
JSON stores data as key and value pairs inside curly braces, and lists inside square brackets. Example: {"name":"Ali","age":30,"skills":["design","code"]}.
Format (pretty print)
Formatting adds line breaks and indentation so you can see the structure. It does not change the data. Use it when you debug an API response or a settings file.
Minify
Minifying removes spaces and line breaks. The data stays the same but the text gets smaller, which helps when you send JSON over a network.
Common JSON errors
- Trailing comma: a comma after the last item, such as [1,2,], is not allowed.
- Single quotes: keys and text must use double quotes, not single quotes.
- Unquoted keys: {name:"Ali"} is invalid. Write {"name":"Ali"}.
- Comments: JSON does not allow // or /* */ comments.
- Missing or extra brackets: every { and [ needs a matching } and ].
- Wrong values: use true, false and null in lowercase. NaN and undefined are not valid.
How to find the error
- Paste your JSON into the JSON Formatter and Validator and press Format.
- If the JSON is invalid, read the message. It tells you the position of the problem.
- Fix the first error and run it again. One mistake can hide others.
Keep secrets safe
Do not paste passwords, tokens or private keys into online tools you do not trust. The ToolsWorld JSON Formatter runs in your browser and does not upload what you paste, but it is still good practice to remove secrets first.