What Is JSON?
JSON — JavaScript Object Notation — is a lightweight, text-based syntax for representing structured data. Although its syntax was derived from JavaScript, the format is language-independent and is widely supported by programming languages, API clients, databases, and configuration tools.
JSON can represent four primitive types—strings, numbers, booleans, and null—and two structured types: objects and arrays. Objects contain named values inside curly braces, while arrays contain ordered values inside square brackets. These structures can be nested to model complex data within the size and depth limits of the software processing it.
JSON Syntax Rules
JSON has a strict, minimal syntax. Violating any of these rules results in a parse error that prevents the data from being read:
Keys must be strings
All property keys must be enclosed in double quotes. Unlike JavaScript object literals, bare identifiers like { name: "Alice" } are invalid JSON.
String values use double quotes
Single quotes are not valid in JSON. All string values must be wrapped in double quotes: { "city": "London" }.
No trailing commas
JSON does not permit a comma after the last item in an object or array. { "a": 1, "b": 2, } is invalid.
No comments
JSON has no comment syntax. // single-line and /* multi-line */ comments will cause a parse error.
Valid value types only
JSON supports six value types: string, number, boolean (true/false), null, object, and array. undefined, Infinity, NaN, and functions are not valid JSON values.
Numbers cannot have leading zeros
00123 is invalid JSON. Numbers must be written as 123, 12.5, -7, or in scientific notation like 1.2e10.
Quote very large integer IDs
JavaScript can round integers beyond 9,007,199,254,740,991 during parsing. Wrap larger identifiers in quotes when every digit must be preserved.
JSON Objects and Arrays
JSON Object { }
An unordered collection of key-value pairs. Keys are strings and should be unique for predictable results. Values can be any valid JSON type.
{
"name": "Alice",
"age": 30,
"active": true
}JSON Array [ ]
An ordered list of values. Elements can be any valid JSON type — including objects and other arrays.
[
"apple",
"banana",
{ "id": 3 }
]JSON in APIs and Web Applications
JSON is commonly used for REST API requests and responses. A browser, mobile app, or backend service can serialize application data as JSON, send it over HTTP with the application/json media type, and parse the response into native data structures.
REST APIs
JSON is a common representation for API request bodies, response bodies, and structured error details.
Databases
MongoDB stores BSON documents with a JSON-like data model, while PostgreSQL and MySQL provide JSON column types.
Config Files
package.json, tsconfig.json, .eslintrc, and many other developer tooling configurations use JSON as their standard format.
JSON vs XML
XML (Extensible Markup Language) remains important in document formats, feeds, enterprise systems, and SOAP services. JSON became common in web APIs because its data model maps naturally to application objects and arrays and browsers provide built-in parsing and serialization APIs.
| Feature | JSON | XML |
|---|---|---|
| Readability | High — minimal syntax | Moderate — verbose tags |
| Markup overhead | No closing tags | Opening and closing tags |
| Browser APIs | JSON.parse / JSON.stringify | DOMParser / XMLSerializer |
| Comments | Not supported | Supported (<!-- -->) |
| Attributes | No concept of attributes | Supports element attributes |
| Schema validation | JSON Schema | XSD / DTD |
| Primary use case | Web APIs, config, storage | Enterprise systems, SOAP |
Why Format and Minify JSON?
✦ JSON Formatting (Beautify)
- ·Converts compact one-line JSON into indented, readable structure
- ·Reveals nesting levels, making hierarchy immediately visible
- ·Makes API responses easier to inspect and debug
- ·Allows visual inspection of keys, values, and data types
- ·Useful for code reviews and documentation
✦ JSON Minification (Compress)
- ·Removes all whitespace, newlines, and indentation
- ·Reduces file size by removing presentation whitespace
- ·Faster HTTP transmission and lower bandwidth costs
- ·Useful when compact payloads or files are preferred
- ·Reduces transfer size for API payloads and saved files
JSON Formatting Best Practices
Continue Your Developer Workflow
Convert spreadsheet exports with the CSV ↔ JSON Converter, generate application types with the JSON to TypeScript Converter, inspect token headers and claims using the JWT Decoder & Debugger, or test matching rules with the Regex Tester & Cheat Sheet.
New to request and response data? Read What Is an API? to understand why modern APIs commonly exchange structured JSON.
To understand how browser applications request that data, execute JavaScript, store state, and update the screen, read How Web Browsers Work.
JSON Standards and References
JSON syntax and interoperability guidance are defined by RFC 8259 and ECMA-404. Browser parsing and serialization behavior is documented by MDN for JSON.parse() and JSON.stringify(). External references open in a new tab.
Your data never leaves your browser
Formatting, validation, and minification run locally in your browser. This tool does not upload or store the JSON you enter. As a general security practice, avoid placing live passwords, private keys, or active API tokens into any webpage unless you trust the device, browser, extensions, and network environment.