JSON (JavaScript Object Notation) is the most widely used format for exchanging data between web applications and APIs. When you see a wall of unstructured text in an API response or configuration file, JSON formatting tools make it immediately readable by adding indentation and line breaks. This guide explains what JSON is, how its structure works, common errors you will encounter, and when to format versus minify.
What is JSON?
JSON is a text-based format for representing structured data. It was derived from JavaScript syntax but is language-independent and supported by virtually every programming language. The format stores data as key-value pairs, making it easy for both humans and machines to read. A simple JSON object looks like this:
{"name": "Alice", "age": 30, "active": true}
When formatted (pretty-printed), the same data becomes:
{
"name": "Alice",
"age": 30,
"active": true
}
JSON Data Types
JSON supports six data types:
- String: Text in double quotes —
"hello" - Number: Integer or decimal —
42,3.14 - Boolean:
trueorfalse(lowercase only) - Null:
null(represents the absence of a value) - Array: An ordered list —
[1, 2, 3] - Object: A collection of key-value pairs —
{"key": "value"}
Common JSON Errors
The JSON Formatter validates your JSON and highlights errors. The most common mistakes are:
- Trailing commas:
{"a": 1, "b": 2,}— the final comma before the closing brace is invalid in JSON (though allowed in JavaScript). - Single quotes: JSON requires double quotes.
{'name': 'Alice'}is invalid. - Unquoted keys: Every key must be a string in double quotes.
{name: "Alice"}is invalid JSON. - Comments: JSON does not support comments.
// commentor/* block */will cause a parse error. - Missing commas between pairs: Each key-value pair in an object (or element in an array) must be separated by a comma.
Formatting vs. Minifying — When to Use Each
Formatting (pretty-printing) adds whitespace and indentation for human readability. Use it when reading API responses, debugging data structures, or editing configuration files. Minifying removes all unnecessary whitespace to reduce file size. Use it when serving JSON over HTTP — minified JSON loads faster and reduces bandwidth costs. The JSON Formatter tool can both format and minify depending on what you need.
Converting Other Formats to JSON
If you have data in CSV format (spreadsheet exports, database dumps), the CSV to JSON converter transforms it into a JSON array of objects automatically. This is useful for importing tabular data into APIs or JavaScript applications that expect JSON input.