JSON formatter and validator
Paste JSON to check it and format it. Errors point to the exact spot.
Check
How to read the result
Paste JSON in the JSON box, or open a .json file. The check below updates as you type: a green “Valid JSON” with the number of keys, how deeply the data is nested and its size, or a red “Not valid JSON” with the line and column of the first mistake, that line with a caret under the spot, and what to change.
Format writes one item per line, indented by 2 spaces, 4 spaces or a tab. Minify removes every space and line break outside the strings. “Sort keys” puts the keys of every object in alphabetical order, at every level; arrays keep their order, because in an array the order is part of the data.
This page does not run your data through JavaScript’s JSON.parse. It reads the text with its own parser and writes back every number and every string exactly as you typed it: 19.90 stays 19.90, and \u00e9 stays \u00e9.
A worked example
The Example button loads a small order. It is valid JSON with 14 keys nested 3 levels deep. Minified it takes 212 bytes; formatted with 2 spaces it takes 323 bytes over 22 lines. The check also warns that 9007199254740993 is too large for JavaScript. Run the same text through JSON.parse and JSON.stringify and three numbers change:
JSON.stringify(JSON.parse('{"trackingId":9007199254740993,"price":19.90}'))
→ {"trackingId":9007199254740992,"price":19.9}Here the formatted and minified results keep 9007199254740993, 19.90 and 5.00 as they were.
JSON syntax at a glance
| Type | Example | Rules |
|---|---|---|
| Object | {"name": "Ana", "age": 31} | Keys are strings in double quotes, each followed by a colon and a value; items are separated by commas. |
| Array | [1, "two", null] | Values in order, separated by commas; they can be of different types. |
| String | "Line one\nLine two" | Double quotes only. Inside, escape \" and \\, and write control characters as \n, \t, \r, \b, \f or \u and four hex digits. |
| Number | -12 3.5 6.02e23 | Decimal only: no leading zeros, no + sign, no hex, no NaN or Infinity. |
| Boolean | true false | Lowercase. |
| Null | null | Lowercase; it means “no value”. |
Spaces, tabs and line breaks between items are ignored. A document holds exactly one value, usually an object or an array.
Common mistakes and how to fix them
| Mistake | Not valid | Valid |
|---|---|---|
| Comma after the last item | {"a": 1, "b": 2,} | {"a": 1, "b": 2} |
| Single quotes | {'name': 'Ana'} | {"name": "Ana"} |
| Key without quotes | {name: "Ana"} | {"name": "Ana"} |
| A comment | {"port": 80 // web} | {"port": 80} |
| Python’s words | {"ok": True, "x": None} | {"ok": true, "x": null} |
| Leading zero | {"zip": 07001} | {"zip": "07001"} |
| Backslash in a path | {"path": "C:\Users"} | {"path": "C:\\Users"} |
| Missing comma | [1 2] | [1, 2] |
| NaN or undefined | {"avg": NaN} | {"avg": null} |
A line break typed inside a string is also an error: write it as \n. Two mistakes are found later than where they happened. A missing comma shows up at the start of the next value, and a bracket that is never closed shows up at the very end of the text; the message then says where that bracket was opened.
Why big numbers change in JavaScript
JavaScript stores every number as a 64-bit floating-point value, which holds whole numbers exactly only up to 2⁵³ − 1 = 9,007,199,254,740,991. Beyond that, JSON.parse quietly rounds to the nearest number it can hold, so database IDs and other 64-bit integers change. That is why Twitter’s API sent each ID twice, as id and as id_str.
The same happens to decimals with more than 17 significant digits, and to numbers too large or too small to hold at all: 1e400 becomes Infinity. When the check finds such numbers it lists them. This page keeps them as written; if your own code has to read them, send them as strings or use a parser with big-number support.
Format or minify?
Format for reading, reviewing and comparing versions: with one item per line, a change is easy to spot. Minify for storing or sending: the example order shrinks from 323 to 212 bytes. Compression on the web (gzip, Brotli) narrows that gap for downloads, but not for what you store.
To compare two JSON files, format both with “Sort keys” on and the same indent, then paste them into the diff checker: the differences left are changes in the data, not in the order or the spacing.
JSON is not JavaScript
JSON took its syntax from JavaScript, but a JavaScript object literal allows things JSON does not: single quotes, keys without quotes, trailing commas, comments, undefined, NaN and functions. An object copied from code into a .json file is the most common source of the errors above.
Some files that look like JSON follow looser rules on purpose. JSONC, used by VS Code’s settings and by tsconfig.json, allows comments; JSON5 also allows single quotes, keys without quotes and trailing commas. This page checks strict JSON (RFC 8259), so it reports those extras as errors.
Files saved by some Windows editors start with an invisible byte order mark (BOM). The standard lets a parser ignore it, so this page accepts it, tells you, and leaves it out of the result.
The payload of a login token (JWT) is JSON too: the JWT decoder decodes and formats it for you.
Questions
Is my JSON sent anywhere?
No. It is checked and formatted by this page, in your browser. Nothing you paste or open is uploaded.
What does the duplicate key warning mean?
The same key appears twice in one object. The standard says keys should be unique and leaves the result up to each program; JavaScript keeps the last value and drops the first without a word. Rename or remove one of them.
Does sorting the keys change my data?
No. In JSON the order of an object’s keys carries no meaning, so a program reading it gets the same data. Arrays are never sorted.
Can it fix my JSON automatically?
It points to the exact spot and says what to change, but it does not guess. A missing quote or bracket can often be closed in more than one place, and a wrong guess would change your data without telling you.
How large a file can it handle?
Files of several megabytes work. Above about 1 MB the check waits a moment after you stop typing, and files up to 20 MB can be opened.