JSON is an open, text-based data interchange format standardized in RFC 8259, designed for human-readable and machine-parseable data transmission.
JSON (JavaScript Object Notation) is a lightweight, language-agnostic, text-based data interchange format standardized under RFC 8259 and ECMA-404. It structures serialized data into human-readable collections of attribute-value pairs (objects) and ordered sequences of values (arrays). JSON is the ubiquitous standard for REST APIs, JSON Web Tokens (JWT), configuration files, NoSQL document databases, and client-server communications across modern software architectures.
Format, validate, repair, and beautify your payloads with our interactive JSON Formatter tool or generate type definitions with JSON to TypeScript.
| Specification | Details |
|---|---|
| Official Standards | IETF RFC 8259 / ECMA-404 / ISO/IEC 21778 |
| MIME Media Type | application/json |
| Standard File Extension | .json |
| Character Encoding | UTF-8 (Strictly mandated by RFC 8259) |
| Language Dependency | 100% Independent (Parsers exist for every major language) |
| Uniform Resource Identifier | RFC 6901 (JSON Pointer) / RFC 9535 (JSONPath) |
JSON defines exactly six data types. Any payload containing types outside this list is invalid JSON:
| Data Type | Syntax Rules | Example |
|---|---|---|
| String | Sequence of Unicode characters enclosed in strict double quotes ("..."). Escaping with \ is supported for \", \\, \/, \b, \f, \n, \r, \t, and \uXXXX. |
"title": "DevFlow Tools" |
| Number | Decimal number (integer or floating-point). Scientific notation (e or E) is valid. Hexadecimal, NaN, and Infinity are forbidden. |
"latencyMs": 42.5, "exp": 1e6 |
| Boolean | Literal lowercase true or false without quotation marks. |
"isActive": true |
| Null | Literal lowercase null denoting empty or absent values. |
"deletedAt": null |
| Object | Unordered set of comma-separated key-value pairs wrapped in curly braces ({}). Keys must be double-quoted strings. |
{"id": 1, "role": "admin"} |
| Array | Ordered sequence of zero or more comma-separated values wrapped in square brackets ([]). May contain mixed data types. |
["TypeScript", 2026, false] |
{
"api": "DevFlow",
"version": 2.0,
"stable": true,
"endpoints": ["/tools", "/glossary"],
"meta": {
"author": "Antigravity Team",
"license": "MIT"
}
}
Many syntax errors occur when developers treat JSON like JavaScript object literals:
| Syntax Feature | JavaScript Object Literal | Strict JSON (RFC 8259) | Fix / Proper JSON Syntax |
|---|---|---|---|
| Trailing Commas | Allowed ([1, 2,]) |
Syntax Error | Remove the trailing comma after the final element. |
| Quotation Style | Single quotes allowed ('name') |
Syntax Error | Always use double quotes ("name"). |
| Unquoted Object Keys | Allowed ({ name: "John" }) |
Syntax Error | Keys must be quoted: { "name": "John" }. |
| Comments | // or /* */ allowed |
Syntax Error | Remove comments or use dedicated config formats like JSONC/TOML. |
| Feature | JSON | XML | YAML | Protocol Buffers (Protobuf) |
|---|---|---|---|---|
| Readability | High | Medium (Verbose tags) | Very High | Binary (Requires .proto schema) |
| Parsing Speed | Very Fast (Native C++) | Slow (DOM/SAX parsing) | Moderate | Ultra-Fast (Pre-compiled binary) |
| Payload Size | Compact | Heavy | Compact | Ultra-Compact (Compressed binary) |
| Typing System | 6 Primitive Types | Strings only (Untyped) | Rich Types | Strongly Typed Schema |
| Schema Validation | JSON Schema | XSD / DTD | JSON Schema / Custom | Protocol Buffers Compiler (protoc) |
| Primary Domain | Web APIs & Client Apps | Enterprise SOAP & RSS | DevOps (K8s, CI/CD) | High-throughput Microservices (gRPC) |
// 1. Serialization with Formatting and Replacer
const config = {
service: "Gateway",
port: 8080,
secretToken: "hidden_token",
created: new Date(),
};
// Pretty-print with 2 spaces and omit sensitive keys
const jsonString = JSON.stringify(config, (key, value) => {
if (key === 'secretToken') return undefined; // Strips key from output
return value;
}, 2);
// 2. Safe Parsing with Error Handling
try {
const parsed = JSON.parse(jsonString);
console.log("Parsed service:", parsed.service);
} catch (error) {
console.error("Malformed JSON received:", (error as Error).message);
}
import json
data = {
"appName": "DevFlow",
"metrics": {"requests": 1500, "errors": 0},
"flags": [True, False, None]
}
# Serialize with proper UTF-8 and clean indentation
json_str = json.dumps(data, indent=2, ensure_ascii=False)
# Parse JSON string back to native dict
parsed_dict = json.loads(json_str)
Douglas Crockford (the creator of JSON) intentionally excluded comments from the RFC standard to prevent developers from parsing custom compiler directives or parser-dependent instructions inside data payloads. For developer configuration files that require comments, use variants like JSON5 or JSONC (JSON with Comments).
The IEEE 754 double-precision floating-point specification used by JavaScript limits safe integers to $\pm(2^{53} - 1)$ (9,007,199,254,740,991). Any 64-bit integer exceeding this range (such as database snowflake IDs or high-resolution timestamps) will suffer rounding corruption. Best practice is to serialize large integers as strings in JSON payloads ("id": "18446744073709551615").
Standard JSON requires an entire array [...] to be loaded and parsed in memory at once. JSON Lines (JSONL) structures data such that each line is an independent, complete JSON object separated by a newline (\n). JSONL is optimal for streaming event logs, machine learning datasets, and big data pipelines because it can be read line-by-line without buffering giant files.
Manually writing TypeScript interfaces or Zod validation schemas for large API responses is error-prone. You can paste any JSON payload into our JSON to TypeScript tool or JSON to Zod generator to produce type-safe definitions in seconds.
Free, browser-based utilities to test, generate, and inspect JSON (JavaScript Object Notation) payloads directly.
Prettify, minify, and validate JSON data instantly.
Convert JSON to TypeScript interfaces or type aliases instantly.
Generate TypeScript interfaces, Zod schemas, and Valibot schemas from JSON.
Convert JSON to Zod schema definitions for runtime validation.
Repair and fix malformed JSON data from AI outputs and copy-paste.
Query and extract data from JSON documents using JSONPath.