Text Diff Tool
Compare two text documents and highlight differences.
Format, validate, and minify JSON data and download.
Format, validate, and minify JSON data and download.
Ctrl/Cmd + Enter to format and Ctrl/Cmd + K to clear.| Problem | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the last comma |
| Single quotes | {'a': 1} | Use double quotes |
| Unquoted key | {a: 1} | Put the key in double quotes |
| Comments | // note | JSON does not allow comments, so delete them |
| Missing bracket | {"a": [1, 2} | Close every bracket and brace |
Format (pretty print) JSON while you read, debug or share it, because the indentation makes the structure easy to follow. Minify JSON before you send it over a network or store it, because removing the spaces and new lines makes the file smaller and faster to load.
Paste this one-line JSON and press Format JSON:
{"name":"Asha","skills":["js","sql"],"active":true}The output puts each key on its own line, indented by two spaces, with the array items indented one more level:
{
"name": "Asha",
"skills": [
"js",
"sql"
],
"active": true
}Press Minify JSON on the result and you get the single line back. Now try an invalid version with trailing commas, such as {"name": "Asha", "skills": ["js", "sql",], }. Formatting stops with an error, because JSON does not allow a comma after the last item. Remove the comma after "sql" and the one before the closing brace, and it formats again.
No. All formatting and validation happens in your browser using JavaScript's native JSON methods. Your data never leaves your device β you can verify this by opening your browser's Developer Tools β Network tab and checking that no requests fire when you paste JSON.
Formatting adds indentation and line breaks so JSON is easy to read. Minifying removes all whitespace so the JSON is smaller and faster to transfer. Both produce identical data β only the whitespace differs.
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, comments, or the values undefined and NaN β none of which are valid JSON. Check for these first, starting with the part you edited last.
Yes. The formatter handles files up to several megabytes without trouble. For extremely large files (tens of megabytes), performance depends on your device β the actual parsing happens locally, so a modern browser will handle most everyday use cases comfortably.
Standard JSON does not support // or /* */ comments. Some tools use "JSONC" (JSON with Comments) or "JSON5" as extensions, but these are not standard and will be rejected by most parsers and APIs.
Two spaces, the most common convention in JavaScript and JSON files (used by npm, ESLint and most style guides). If your project uses four spaces or tabs, your code editor can re-indent the output after you paste it.