JSON Formatter
Pretty-print is not the hard part. The first syntax error is, and JSON will not mention the second one until you fix the first.
Pretty-print is not the hard part. The first syntax error is, and JSON will not mention the second one until you fix the first.
Paste the blob. Hit Prettify. If it fails, the line number is the only thing that matters. Minify is for the copy you send, not the copy you read.
How to use it
- Read the first error line. Parsers stop at the first problem: missing comma, trailing comma, single quotes, unquoted keys.
- Duplicate keys are legal and a footgun. Most engines keep the last one. The formatter will not warn you.
- Integers above
Number.MAX_SAFE_INTEGER(2⁵³−1) are not safe in JavaScript.9007199254740993comes back as9007199254740992. Keep big IDs as strings. - Comments are not JSON. JSONC (
//,/* */) fails here. Strip comments first. - Indent 2 for JS/TS unless the repo already uses 4. Minify does not change meaning, only bytes.
When it breaks
- Trailing commas from JS objects fail. So do single quotes.
undefinedandNaNare not JSON. You get Unexpected token.- A pretty document can still be the wrong shape for your API. This is syntax, not schema.
Input
Loading editor...
Output
Loading editor...
Features
- First syntax error reported with a line and column, not a generic "Unexpected token"
- Pretty-print or minify after the document actually parses
- Indent of 2, 4, or 8 spaces so diffs stay consistent with the repo
- Refuses JSONC: comments and trailing commas are errors, not silently stripped
- Shows what JSON.parse did with duplicate keys (last write wins)
- Flags integers past Number.MAX_SAFE_INTEGER that JS will round
Common Use Cases
- Find the exact line a minified API body failed to parse
- See why a VS Code settings.json (JSONC) is not valid JSON
- Catch a duplicate key that overwrote a config value
- Check whether a 64-bit id survived JSON.parse as a Number
- Pretty-print a payload before a code review without changing values
Pretty-print is not the hard part
Pretty-print is not the hard part. The first syntax error is, and JSON will not mention the second one until you fix the first.
Paste the blob. Hit Prettify. If it fails, the line number is the only thing that matters. Minify is for the copy you send, not the copy you read.
Read the first error line. Parsers stop at the first problem: missing comma, trailing comma, single quotes, unquoted keys. Duplicate keys are legal and a footgun. Most engines keep the last one. The formatter will not warn you.
Integers above Number.MAX_SAFE_INTEGER (2⁵³−1) are not safe in JavaScript. 9007199254740993 comes back as 9007199254740992. Keep big IDs as strings. Comments are not JSON. JSONC (//, /* */) fails here. Strip comments first. Indent 2 for JS/TS unless the repo already uses 4. Minify does not change meaning, only bytes.
Examples
{"id":"usr_01","ok":true,"n":42}{
"items": [1, 2, 3,],
}{
// feature flag
"enabled": true
}{
"port": 3000,
"port": 8080
}{
"snowflake": 12345678901234567890
}Frequently Asked Questions
Pretty-print is not the hard part. The first syntax error is, and JSON will not mention the second one until you fix the first. Read the first error line. Parsers stop at the first problem: missing comma, trailing comma, single quotes, unquoted keys.
Duplicate keys are legal and a footgun. Most engines keep the last one. The formatter will not warn you.
Integers above Number.MAX_SAFE_INTEGER (2⁵³−1) are not safe in JavaScript. 9007199254740993 comes back as 9007199254740992. Keep big IDs as strings.
Comments are not JSON. JSONC (//, /* */) fails here. Strip comments first. Trailing commas from JS objects fail. So do single quotes. undefined and NaN are not JSON. You get Unexpected token.
Indent 2 for JS/TS unless the repo already uses 4. Minify does not change meaning, only bytes. A pretty document can still be the wrong shape for your API. This is syntax, not schema.