~/tools/json-formatter
JSON Formatter & Validator
Format, minify, and validate JSON instantly — runs entirely in your browser. Zero server calls, zero data sent.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, human-readable data interchange format derived from JavaScript object syntax. It was popularised by Douglas Crockford in the early 2000s and is now defined by RFC 8259 and ECMA-404. JSON has effectively replaced XML as the dominant format for REST APIs, configuration files, NoSQL databases, and inter-service communication.
JSON supports exactly six data types: string, number, boolean (true/false), null, object (key-value pairs), and array (ordered list). Every other data type must be serialized as one of these six.
JSON Data Types with Examples
JSON supports exactly six data types, and every value in a document must be one of them. Understanding these types is essential because strict parsers will reject anything that doesn't conform — using JavaScript's undefined, Python's None, or a raw Date object will all cause parse failures. Below is a complete breakdown with examples and the common gotchas for each type.
Valid JSON Rules & Common Mistakes
JSON has a deliberately minimal and strict syntax. While that makes parsers easy to implement, it also means small mistakes — a trailing comma after the last item, a single-quoted string, or an inline comment — will cause the entire document to fail validation. These are the errors that come up most often when copying JSON from browser DevTools, log files, or configuration templates.
JSON vs XML vs YAML
JSON didn't emerge in a vacuum — it was designed as a lighter alternative to XML and has since been joined by YAML as another human-friendly format. The right choice depends on context: REST APIs favour JSON for its compact size and native browser support, CI/CD pipelines favour YAML for its readability and comment support, and enterprise integrations sometimes still require XML for its schema validation and namespace capabilities.
Key Features of This Tool
This formatter was built to handle the real-world messiness of JSON — not just well-formed inputs. Whether you're debugging a malformed API response, exploring a deeply nested structure, or comparing two versions of a config file, every feature here is designed to reduce the time between "something is wrong" and "now I understand it."
Format
Beautify JSON with 2-space indentation and syntax highlighting
Minify
Strip all whitespace for the smallest possible payload size
Validate
Detect and report exact syntax errors with line/column numbers
Auto-fix
Repair trailing commas, single quotes, and other common mistakes
Tree View
Explore deeply nested structures with expand/collapse and path copy
Diff View
Compare two JSON documents side-by-side with highlighted changes