Developer
How to Format JSON: A Practical Developer Guide
Learn how to format JSON, spot common syntax mistakes, and make API responses easier to read with a free browser-based JSON formatter.
JSON (JavaScript Object Notation) is a common text format for moving structured data between applications. A long API response can be hard to read, so formatting adds indentation and line breaks without changing the data.
What valid JSON looks like
JSON uses objects, arrays, strings, numbers, booleans and null. Object property names and string values use double quotes.
{"name":"Asha","active":true,"skills":["HTML","JavaScript"]}
Formatted, the same data is easier to inspect:
{
"name": "Asha",
"active": true,
"skills": ["HTML", "JavaScript"]
}
How to format JSON
- Start with JSON text.
- Paste it into a formatter.
- Choose consistent indentation.
- Review the formatted structure before copying it elsewhere.
The Internet Toolbox JSON Formatter formats JSON directly in your browser, making nested objects and arrays easier to inspect.
Common JSON errors
Property names and strings need double quotes. Properties are separated by commas, braces and brackets must be balanced, and standard JSON does not allow comments or trailing commas.
- Wrong:
{'name': 'Asha'} - Correct:
{"name": "Asha"} - Wrong:
{"name": "Asha",} - Correct:
{"name": "Asha"}
JSON versus a JavaScript object
JavaScript object literals can use unquoted property names, single-quoted strings, functions and comments. JSON is stricter because it is a data-interchange format.
Why formatting helps when debugging APIs
Readable indentation makes missing fields, unexpected nesting and incorrect assumptions about an API response easier to spot. It is useful for debugging, documentation and reviewing data before transforming it.
Quick JSON checklist
- Use double quotes around property names and strings.
- Separate properties and array items with commas.
- Keep braces and brackets balanced.
- Use
true,falseandnullas JSON values without quotes. - Format or validate unfamiliar API responses before relying on them.
If a formatter reports an error, inspect the reported location and check quotes, commas and brackets before trying again.
Try it yourself
Related tools
Keep reading