Guide · Updated 2026-10-06

How to Format and Validate JSON

Fix JSON syntax errors fast and learn the rules that trip people up.

JSON is the standard format for APIs and configuration files. It is strict, so a single stray comma can break an entire request.

Common errors

  • Trailing commas after the last item are not allowed.
  • Single quotes are invalid. Keys and strings need double quotes.
  • Unquoted keys must be quoted.
  • Comments are not part of JSON.

Validate and format

Paste your data into the JSON Formatter. If it is invalid, the error message points to the problem. If it is valid, choose an indentation level to make it readable, or minify it for transport.

Need it in a spreadsheet? Convert arrays of objects with JSON to CSV.

A quick example

This is invalid because of a trailing comma and single quotes: {'name': 'Ada', 'age': 36,}. The valid version is {"name": "Ada", "age": 36}. A formatter points to the position of the first error so you can fix problems one at a time.

Good habits

  • Validate JSON before you send it to an API or commit it to a repository.
  • Use a consistent indentation of two or four spaces in files people read.
  • Minify JSON that is sent over the network to save bandwidth.
  • Keep numbers as numbers and dates as ISO 8601 strings such as 2026-10-06.

Security note

Do not paste live secrets such as API keys or tokens into online tools unless you know they run locally. The JSON Formatter processes text in your browser and does not send it anywhere.

Frequently asked questions

Can JSON contain comments? No. If you need comments, use a format such as YAML or JSON5, or strip comments before parsing.

What is the difference between JSON and a JavaScript object? JSON is a text format with stricter rules: keys must be double-quoted strings and values cannot be functions or undefined.

Try the tools