JSON is the language that apps and websites use to exchange data. APIs return it, configuration files are written in it, and logs are full of it. The problem is that machines often produce JSON as one long line, which is almost impossible for humans to read. Learning how to format JSON – and how to fix the errors that stop it from working – will save developers, testers and analysts a lot of frustration.
What JSON looks like
JSON (JavaScript Object Notation) stores data as names and values:
{"name":"Ada","age":36,"skills":["maths","programming"],"active":true}
The same data, pretty printed:
{
"name": "Ada",
"age": 36,
"skills": ["maths", "programming"],
"active": true
}
Same content, but the second version shows the structure at a glance.
Beautifying JSON in seconds
With the free JSON Formatter:
- Paste your JSON into the box.
- Click format. The tool adds indentation and line breaks.
- Read the error message if the JSON is invalid – it tells you where the problem is.
- Copy the result, or minify it again for production use.
Everything runs in your browser, so API keys and private data are not sent to a server.
The JSON rules that cause most errors
A JSON validator will reject your data if it breaks any of these rules:
- Keys must be in double quotes.
{name: "Ada"}is invalid;{"name": "Ada"}is correct. - Strings use double quotes only. Single quotes are not allowed.
- No trailing commas.
["a", "b",]is invalid – remove the last comma. - No comments. Standard JSON does not allow
//or/* */comments. - Values must be valid types: string, number, true, false, null, object or array.
undefinedandNaNare not allowed. - Brackets must match. Every
{needs a}and every[needs a]. - Special characters in strings must be escaped, for example
\"for a quote and\nfor a new line.
When you get a syntax error, check the line the formatter points to, then look just before it – the real mistake is often a missing comma or quote on the previous line.
Pretty print vs minify
- Pretty print for reading, debugging and storing config files in version control.
- Minify json (remove all spaces and line breaks) for sending data over the network, where every byte counts.
Related tools for working with APIs
JSON rarely travels alone. These tools help when debugging web apps:
- JWT Decoder – inspect the header and payload of JSON Web Tokens
- Base64 Encode and Decode – decode Base64-encoded data you find in APIs and emails
- URL Encode and Decode – fix query strings with special characters
- Unix Timestamp Converter – turn numbers like 1760745600 into readable dates
- Regex Tester – test patterns for extracting values
- HTTP Status Code Checker – see what an endpoint returns
Tips for working with JSON
- Validate before you deploy. One missing comma in a config file can break a whole app.
- Use consistent naming – camelCase or snake_case, but not both.
- Keep secrets out of JSON files that are committed to Git.
- Store dates as ISO 8601 strings (2026-10-19T08:00:00Z) or Unix timestamps, consistently.
- Keep nesting shallow. Deeply nested objects are hard to read and awkward to query. If you find yourself five levels deep, consider flattening the structure.
- Use arrays for lists, objects for records. A list of users is an array of objects, not an object with numbered keys.
Where you will meet JSON
Almost everywhere in modern software: REST APIs, mobile app backends, package.json and composer.json files, VS Code settings, browser local storage, webhooks from payment providers and exports from tools such as Google Analytics. Being comfortable reading it is a core skill for anyone who works with the web.
Summary
Now you know how to format JSON: paste it into a formatter to make it readable, use the error message to find problems, and remember the core rules – double quotes, no trailing commas and no comments. Try the free JSON Formatter the next time an API hands you a wall of text.