JSON Formatter

JSON Formatter

Updated August 27, 2026

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

  1. Read the first error line. Parsers stop at the first problem: missing comma, trailing comma, single quotes, unquoted keys.
  2. Duplicate keys are legal and a footgun. Most engines keep the last one. The formatter will not warn you.
  3. Integers above Number.MAX_SAFE_INTEGER (2⁵³−1) are not safe in JavaScript. 9007199254740993 comes back as 9007199254740992. Keep big IDs as strings.
  4. Comments are not JSON. JSONC (//, /* */) fails here. Strip comments first.
  5. 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.
  • undefined and NaN are not JSON. You get Unexpected token.
  • A pretty document can still be the wrong shape for your API. This is syntax, not schema.

Input

0 lines · 0 chars

Loading editor...

Output

0 lines · 0 chars read-only

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

Valid - Valid object (will pretty-print)
{"id":"usr_01","ok":true,"n":42}
Invalid - Trailing comma (JSONC, not JSON)
{
  "items": [1, 2, 3,],
}
Invalid - JSONC comment (will not parse)
{
  // feature flag
  "enabled": true
}
Valid - Duplicate key: last write wins
{
  "port": 3000,
  "port": 8080
}
Valid - Unsafe integer (precision lost in JS)
{
  "snowflake": 12345678901234567890
}

Frequently Asked Questions

Why do I only see the first error?

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.

Will the formatter warn me about duplicate keys?

Duplicate keys are legal and a footgun. Most engines keep the last one. The formatter will not warn you.

Why did a large integer change after Prettify?

Integers above Number.MAX_SAFE_INTEGER (2⁵³−1) are not safe in JavaScript. 9007199254740993 comes back as 9007199254740992. Keep big IDs as strings.

Why do comments and trailing commas fail?

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.

Does minify change the meaning? Is pretty JSON valid for my API?

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.

Common Mistakes

Trailing commas from JS objects fail. So do single quotes.
`undefined` and `NaN` are not JSON. You get Unexpected token.
A pretty document can still be the wrong shape for your API. This is syntax, not schema.