How it works
- Paste or open your JSON.
- Choose beautify, minify or sort keys.
- Copy or download the result.
Why use it
- Precise error location and message.
- Indent with 2 or 4 spaces or tabs.
- Sorts keys and keeps your original tokens intact.
- Tolerates comments and trailing commas.
Formatting and validating JSON, and fixing the usual errors
Valid JSON in one look
Paste JSON or open a file and it is checked as you type. Valid JSON gets a green mark and is shown formatted; invalid JSON gets a red mark, the line with the problem is highlighted in the editor, and the reason is named, such as a missing comma or an unexpected end of the text. Since nothing leaves the page, it is safe for API responses, configuration files and data that contains personal details or keys.
The errors almost everyone makes
JSON is stricter than the JavaScript it looks like. These five cause most invalid files:
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma after the last item | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ada'} | {"name": "Ada"} |
| Keys without quotes | {name: "Ada"} | {"name": "Ada"} |
| Comments | {"a": 1 // note} | No comments in JSON |
| Values JavaScript allows | NaN, undefined, 0x1F | null, or a plain number |
Configuration files for editors and build tools often use JSONC, JSON with comments and trailing commas. Switch on Allow comments and trailing commas to read them without errors; the formatted output then keeps the comments.
Formatting and minifying
Two spaces is the most common style and is used by most JavaScript projects; four spaces and tabs are common elsewhere. Minify removes every space and line break that is not inside a string, which makes the smallest text for sending over a network or storing in a database field. Sort keys orders the keys of every object alphabetically, at every level, which makes two JSON files much easier to compare in the diff checker.
Exploring big documents in the tree
The tree view shows objects and arrays as nested lists you can fold and unfold, with the number of items in each. Click a key to copy its path, such as $.data.items[3].price, in the JSONPath style that query tools and many test frameworks use. Long arrays show their first 100 items, with a button to show more, so even large API responses stay quick to browse.
Related tasks
- Turn JSON into a spreadsheet with JSON to CSV, which flattens nested objects into columns.
- Convert to YAML or XML with JSON to YAML and JSON to XML.
- Read a token that contains JSON with the JWT decoder.
If something goes wrong
- It is invalid but looks fine. Check the highlighted line and the one before it: a missing comma is reported where the next value starts.
- Curly quotes. Text copied from a document or chat can turn
"into typographic quotes, which JSON does not accept. Retype them. - A long number looks different in the tree. The tree shows values as JavaScript reads them, which cannot hold more than about 16 significant digits exactly. The formatted text keeps every number as written; still, long IDs are safer stored as strings.
Questions and answers
How do I validate JSON?
Paste it in. If it is invalid, the error message shows the line and column of the problem.
Will formatting change my numbers or strings?
No. The formatter edits whitespace only, so big numbers and escapes are preserved exactly.
Is my data sent anywhere?
No. Everything is processed in your browser.
Related guides
CSV, Excel or JSON: which format for your data?
We saved the same 100,000 row table as CSV, as an Excel workbook and as JSON, then compared the sizes, how fast each one reads in code, and what goes wrong with dates, leading zeros and long numbers.