Free JSON Formatter & Validator
Format, minify, validate and explore JSON — with live error detection, tree view, key sorting and syntax highlighting. All in your browser.
Input JSON
Output
What Is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It was formalized by Douglas Crockford in the early 2000s as a subset of JavaScript's object literal syntax — though today it's a language-independent standard used everywhere.
Every modern API speaks JSON. Every configuration file — from package.json to tsconfig.json — uses it. Every web framework produces and consumes it. It has effectively replaced XML for data interchange because it's simpler, smaller and directly parsable in every programming language.
The JSON data types
| Type | Example | Notes |
|---|---|---|
| String | "hello" | Must use double quotes, not single |
| Number | 42, 3.14, -1e10 | No leading zeros, no NaN, no Infinity |
| Boolean | true, false | Always lowercase |
| Null | null | Not undefined, not None, not nil |
| Object | {"key": "value"} | Keys must be strings in double quotes |
| Array | [1, 2, 3] | Ordered, can mix types |
That's the entire spec. Everything else — dates, binary data, custom types — has to be encoded into these six primitives.
Beautify vs Minify — when to use each
| Mode | Purpose | When to use |
|---|---|---|
| Beautify | Adds indentation and line breaks | Reading, debugging, code review, teaching |
| Minify | Removes all whitespace | API payloads, network transmission, storage |
Minifying a typical API response saves 30–50% of bytes. For a large dataset that's transmitted millions of times per day, this compounds into real bandwidth savings.
Common JSON syntax errors
- Trailing commas.
[1, 2, 3,]is invalid — the last item can't be followed by a comma. - Single quotes.
{'name': 'value'}is invalid — JSON only accepts double quotes. - Unquoted keys.
{name: "value"}is invalid — object keys must be strings. - Comments.
// commentand/* comment */are not valid in JSON. (JSON5 and JSONC allow them; standard JSON does not.) - NaN and Infinity. JSON numbers must be finite. Represent them as strings or null.
- Undefined. JSON has no
undefined. Usenullinstead. - Missing commas. Every key-value pair except the last must be followed by a comma.
- Unclosed brackets. A single missing
}or]invalidates the entire document.
When to use the tree view
The tree view renders JSON as a collapsible hierarchy. It's useful when:
- Exploring a new API response. Click through nested objects instead of scrolling through indented text.
- Comparing deep structures. Collapse sections you don't care about to focus on one branch.
- Understanding complex configs. A 500-line
package.jsonbecomes navigable in seconds. - Presenting to non-developers. The tree structure is more intuitive than indented text for showing how data is organised.
Sorting keys
JSON object key order is technically not guaranteed by the spec — but in practice every implementation preserves insertion order. Sorting keys alphabetically is useful for:
- Diffing two JSON documents. If keys are in the same order, diff tools produce cleaner output.
- Deterministic output. Tests and build artefacts that must be byte-identical.
- Human readability. Finding a key in a large object is faster when keys are sorted.
Sorting is recursive — every nested object gets sorted too.
Common use cases
Debug API Responses
Format a tangled API response to find the field you need.
Edit Config Files
Format package.json, tsconfig.json, or any config before editing.
Shrink Payloads
Minify JSON before sending it over the network or embedding it in HTML.
Explore Deep Data
Use the tree view to navigate complex nested structures.
Validate Before Deploy
Catch syntax errors in config files before they break production.
Compare JSON
Sort keys and format both documents for a clean diff.
Learn JSON
Format examples to see the exact structure with colours.
Prepare Data
Format JSON before pasting into databases or import tools.
Privacy and security
This JSON formatter runs entirely in your browser. Parsing uses the native JSON.parse, formatting uses JSON.stringify, and syntax highlighting is done with a custom tokenizer — all local. Your JSON never leaves your device. Safe for API keys, credentials, proprietary data and any other sensitive payload.