JSON Formatter

Format, beautify, validate, and minify JSON online with an interactive tree viewer

Lines: 1Size: 0 B
Indent:

JSON Syntax: The Five Mistakes That Break It

The rules (RFC 8259)

JSON looks like JavaScript object syntax but is stricter. Most parse errors come down to five things:

  • Keys and strings require double quotes: `'name'` (βœ—) β†’ `"name"` (βœ“)
  • No trailing commas: `[1, 2, 3,]` (βœ—)
  • No comments β€” `//` or `/* */` makes it invalid JSON
  • No `undefined`, `NaN`, or `Infinity` β€” only `null`
  • Newlines inside strings must be escaped as `\n`

Debugging tip

The reported error position often points *after* the real problem β€” check the comma or quote on the preceding element first. Formatting also doubles as validation: if it formats and folds, it parses.

Frequently Asked Questions

Related Tools

Sources & References

Content last reviewed: 2026-08-22