JSON Formatter & Validator
Paste JSON to instantly beautify, minify, or validate it. Errors point to the exact line and column — everything runs in your browser, nothing is uploaded.
By Alex van den Berg · Last reviewed · How we test our tools
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based data format used almost everywhere data moves between systems — API responses, configuration files, log entries, and browser localStorage. It is defined by two structures: an unordered set of key/value pairs (an object, wrapped in { }) and an ordered list of values (an array, wrapped in [ ]). Values can be strings, numbers, booleans, null, or nested objects and arrays.
JSON's popularity comes from being both human-readable and directly parseable by JavaScript's JSON.parse(), with equivalent libraries in every major language. It replaced XML as the default web data format because it is far less verbose — no closing tags, no attributes-vs-elements ambiguity.
Common JSON errors and how to fix them
JSON is stricter than a JavaScript object literal. These are the mistakes that trip people up most often:
| Mistake | Invalid | Fix |
|---|---|---|
| Trailing comma | {"a":1,"b":2,} | {"a":1,"b":2} |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comments | {"a":1} // note | {"a":1} |
| NaN / Infinity | {"a": NaN} | {"a": null} |
| Leading zero | {"a": 012} | {"a": 12} |
JSON vs. XML vs. YAML
| Format | Readability | Comments? | Typical use |
|---|---|---|---|
| JSON | Good, compact | No | APIs, config, data interchange |
| XML | Verbose | Yes | Legacy enterprise systems, documents |
| YAML | Very good | Yes | CI/CD configs, Kubernetes manifests |
Frequently Asked Questions
Is my JSON data uploaded anywhere?
No. All parsing, formatting, and validation happens locally in your browser using JavaScript. Your data is never sent to a server, which makes this safe to use with API keys, customer records, or other sensitive payloads.
Why does my JSON say "Unexpected token" when it looks correct?
The most common causes are a trailing comma after the last item in an object or array, single quotes instead of double quotes around strings, or an unquoted object key. JSON is stricter than JavaScript object literals — see the common errors table above for the full list with fixes.
What is the difference between JSON.parse and this validator?
This tool uses JSON.parse internally but wraps it to report the exact line and column of a syntax error, plus a plain-English explanation, rather than just throwing a raw exception in the browser console.
Can JSON have comments?
No — standard JSON does not support comments (// or /* */). If a config file needs comments, that usually means it is JSON5, JSONC, or YAML, not strict JSON. This validator follows the strict JSON specification, RFC 8259.
Why sort keys alphabetically?
Sorting keys makes it far easier to diff two JSON files or compare API responses, since key order becomes deterministic. It has no effect on how the data is parsed — JSON objects are inherently unordered collections, so reordering keys never changes meaning.
What's the maximum JSON size this tool can handle?
Since everything runs in your browser's memory, the practical limit depends on your device — most modern browsers handle tens of megabytes of JSON without issue. For files in the hundreds of megabytes, a command-line tool like jq is faster and more memory-efficient.
Sources & further reading
- RFC 8259 — "The JavaScript Object Notation (JSON) Data Interchange Format", IETF. rfc-editor.org
- MDN Web Docs — "JSON.parse()" and "JSON.stringify()" reference. developer.mozilla.org