The basic JSON rules
Objects use curly braces and contain key-value pairs. Keys must be double-quoted strings. Arrays use square brackets. Strings use double quotes, and values can be strings, numbers, booleans, null, objects or arrays.
Common mistakes
- Using single quotes around keys or strings.
- Leaving a trailing comma after the final item.
- Forgetting a comma between two properties.
- Missing a closing brace or bracket.
- Putting comments inside standard JSON.
A practical debugging workflow
Start by formatting the smallest version of the payload that fails. Then inspect the line where the parser stops and the property immediately before it. In many cases the reported location is where the parser noticed the problem, not where the typo originally occurred.
Why formatted JSON helps
Indented output makes nesting visible. This is especially useful when checking API responses, configuration files and objects passed between browser and server code.
For a quick browser-based formatter, open the SmartToolz developer tools →
Want the quick how-to?
Follow the dedicated step-by-step guide for this topic and get started in minutes.