JSON formatter guide
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, apps and configuration files. It is easy for machines to read, but a 5,000-character API response on a single line is almost impossible for a person to scan. A JSON formatter (also called a JSON beautifier or pretty printer) adds line breaks and indentation so you can see the structure at a glance.
This tool combines a formatter, a strict JSON validator (RFC 8259 / ECMA-404), a JSON viewer and converters in one page. Unlike most online JSON tools, nothing is sent to a server — the processing code runs in your browser, which makes it safe for API keys, customer data and internal configuration.
Most common JSON errors and how to fix them
| Error | Wrong | Correct |
|---|---|---|
| Single quotes | {'name': 'Ann'} | {"name": "Ann"} |
| Trailing comma | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Unquoted key | {name: "Ann"} | {"name": "Ann"} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Comments | {"a": 1 // note} | {"a": 1} |
| Python literals | {"ok": True, "x": None} | {"ok": true, "x": null} |
| NaN / undefined | {"v": NaN} | {"v": null} |
| Line break in string | "line 1 ↵ line 2" | "line 1\nline 2" |
Press Fix JSON and the tool repairs all of the above automatically. You can undo the repair with Ctrl+Z.
JSONPath cheat sheet
Open the filter (funnel icon above the result) and type an expression. The result updates as you type.
| Expression | Returns |
|---|---|
$.store.name | The name property of store |
$.items[0] | The first item |
$.items[-1] | The last item |
$.items[0:5] | The first five items |
$.items[*].id | The id of every item |
$..email | Every email, at any depth |
$.items[?(@.price < 10)] | Items cheaper than 10 |
$.users[?(@.role == 'admin')].name | Names of all admins |
$.users[?(@.email =~ /gmail/i)] | Users with a Gmail address |
$.items.length | Number of items |
JSON vs YAML vs XML vs CSV
| Format | Best for | Nesting | Comments |
|---|---|---|---|
| JSON | APIs, web apps, NoSQL databases | Yes | No |
| YAML | Config files (Docker, Kubernetes, CI) | Yes | Yes |
| XML | Enterprise systems, SOAP, RSS, office files | Yes | Yes |
| CSV | Spreadsheets (Excel, Google Sheets), data exports | No (flattened) | No |
Tips
- Keyboard: Ctrl+Enter formats, Ctrl+Shift+Enter minifies, Ctrl+F searches, Ctrl+S downloads (⌘ on Mac).
- Excel in Europe: choose the semicolon delimiter in Settings — Excel in Germany, France, Spain and Italy uses “;” to split columns.
- Minify before shipping: minified JSON is typically 20–40% smaller, which means faster API responses and smaller bundles.
- Stringified JSON such as
"{\"id\":1}"from logs is detected automatically — click “Unescape it”. - JSON Lines / NDJSON (one JSON object per line, common in logs and BigQuery exports) is validated line by line.