What Is JSON?
JSON (JavaScript Object Notation) is a lightweight data interchange format used by virtually every modern web application. When your browser fetches data from an API, the response is almost certainly JSON. When a mobile app syncs with a server, the payload is JSON. When configuration files store settings, they are increasingly JSON. It has become the universal language of data exchange on the web.
Format, validate, and minify JSON with WritePadPro's JSON Formatter & Validator — paste JSON data and get properly indented, validated output plus a collapsible tree view.
JSON was formalized by Douglas Crockford in the early 2000s as a simpler alternative to XML. Its syntax is derived from JavaScript object notation but is language-independent — every programming language has JSON parsing libraries. Its simplicity (only 6 data types, minimal syntax rules) made it the dominant format for web APIs, where it has largely replaced XML.
JSON Syntax Rules
JSON has strict syntax rules. Unlike JavaScript, there is no room for variation — a single syntax error makes the entire document invalid.
The 6 Data Types
| Type | Example | Notes |
|---|---|---|
| String | "hello" | Must use double quotes (single quotes are invalid) |
| Number | 42, 3.14, -7 | No leading zeros, no hex, no NaN/Infinity |
| Boolean | true, false | Lowercase only (True/False are invalid) |
| Null | null | Lowercase only (Null/NULL are invalid) |
| Array | [1, 2, 3] | Ordered list of values, comma-separated |
| Object | {"key": "value"} | Unordered key-value pairs, keys must be strings |
The Rules That Trip People Up
- No trailing commas:
{"a": 1, "b": 2,}is INVALID. The comma after the last item is a syntax error. - No comments: JSON does not support
// commentsor/* comments */. Many developers wish it did. - Double quotes only:
{'key': 'value'}is INVALID. Keys and strings must use double quotes. - No undefined: JavaScript's
undefinedis not a valid JSON value. Usenullinstead. - No functions: JSON is data, not code. Functions cannot be serialized to JSON.
- Keys must be strings:
{42: "value"}is INVALID. Keys must be quoted strings:{"42": "value"}.
WritePadPro's JSON Formatter & Validator validates syntax and points to the first error — line, column, and the surrounding text — in browsers that report a position (Chrome, Edge, and Firefox), making these mistakes easy to find and fix. For generating JSON-LD structured data, see our Schema Markup Guide.
Why Format JSON?
Readability
Raw API responses arrive as single-line minified JSON:
{"users":[{"id":1,"name":"John","email":"[email protected]","roles":["admin","editor"]},{"id":2,"name":"Jane","email":"[email protected]","roles":["viewer"]}]}Formatted (prettified) with 2-space indentation:
{
"users": [
{
"id": 1,
"name": "John",
"email": "[email protected]",
"roles": ["admin", "editor"]
},
{
"id": 2,
"name": "Jane",
"email": "[email protected]",
"roles": ["viewer"]
}
]
}The structure is immediately clear: an object with a "users" array containing two user objects, each with id, name, email, and roles.
Debugging
When an API returns unexpected data, formatting reveals the structure. Is the response an array or an object? Is a field missing? Is a value null when it should be a string? These questions are answerable at a glance with formatted JSON — and nearly impossible with minified JSON.
Validation
Formatting tools validate JSON syntax as a side effect of parsing. If the JSON is invalid (missing comma, unquoted key, trailing comma), the formatter reports the error with the line number and character position. This is faster than debugging by reading through hundreds of characters of minified JSON.
Common JSON Errors and How to Fix Them
| Error | Invalid Example | Fixed |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'John'} | {"name": "John"} |
| Unquoted keys | {name: "John"} | {"name": "John"} |
| Comments | {"a": 1} // comment | {"a": 1} (remove comment) |
| Undefined value | {"a": undefined} | {"a": null} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Leading zeros | {"port": 08080} | {"port": 8080} |
| NaN or Infinity | {"val": NaN} | {"val": null} or {"val": 0} |
WritePadPro's formatter rejects all of these errors, one at a time, and shows where parsing failed in browsers that report a position. For CSS formatting alongside JSON config files, see our CSS Formatting Guide.
JSON Formatting vs Minification
| Aspect | Formatted (Pretty) | Minified |
|---|---|---|
| Purpose | Human readability | Machine transmission |
| Whitespace | Indentation + line breaks | No whitespace |
| File size | Larger (depends on nesting and indent size) | Smaller (baseline) |
| Use case | Config files, debugging, documentation | API responses, storage, transmission |
| Parsing speed | Nearly the same (parsers skip whitespace) | Nearly the same |
Like CSS, the formatting choice depends on context. Config files (package.json, tsconfig.json, settings files) should be formatted for readability. API responses and stored data should be minified for efficiency.
JSON in Practice
API Responses
Most REST APIs return JSON. GraphQL APIs return JSON. Many modern web services communicate mainly in JSON. When debugging API issues, formatting the response is the first step — it reveals the data structure, identifies missing fields, and shows unexpected values.
Configuration Files
package.json (Node.js), tsconfig.json (TypeScript), .eslintrc.json (ESLint), settings.json (VS Code), manifest.json (PWA/Chrome extensions) — the JavaScript ecosystem runs on JSON configuration. These files are usually stored formatted (often with 2-space indentation) because humans edit them regularly.
Data Storage
Document databases such as MongoDB, CouchDB, and Firebase store data as JSON or JSON-like documents. Log files in JSON Lines format (one JSON object per line) enable structured logging. Data interchange between microservices uses JSON payloads. For building and testing code that produces JSON, use our Code Playground.
Using WritePadPro's JSON Formatter
WritePadPro's JSON Formatter & Validator formats, validates, and minifies JSON data instantly.
Step 1: Paste JSON
Open the JSON Formatter & Validator and paste your JSON data — from API responses, config files, database exports, or any JSON source.
Step 2: Beautify, Minify, or Validate
Click Beautify for readable output with 2-space indentation. Click Minify for compact, single-line output. Click Validate to check the JSON without changing it. If the JSON has a syntax error, the tool shows the browser’s error message and, in Chrome, Edge, and Firefox, the line, column, and surrounding text.
Step 3: Review
The formatted output makes the data structure clear, with nested objects and arrays indented. Switch to Tree View to collapse and expand nested sections and see property and item counts. A stats line shows the line count and size, or how much smaller the minified version is.
Step 4: Copy and Use
Click Copy JSON or Download .json. Use formatted JSON for debugging, documentation, or config files, and minified JSON for API payloads, storage, or transmission.
Privacy
All formatting and validation runs locally in your browser. The tool validates with the built-in JSON.parse() and then re-indents your original text, so even very large numbers keep every digit. Your JSON data — including API responses, database records, and configuration — is never transmitted to any server.
Summary
JSON is the universal data format of the modern web — used in API responses, configuration files, data storage, and inter-service communication. Its strict syntax (double quotes only, no trailing commas, no comments, 6 data types) makes validation essential for debugging.
Formatting (prettifying) JSON makes it human-readable for debugging and configuration. Minifying JSON makes it compact for transmission and storage. Both operations preserve the data identically — only the whitespace changes.
Format, validate, and minify JSON with WritePadPro's JSON Formatter & Validator — instant parsing with error detection, running entirely in your browser.