N NotAtAll

How to Format JSON and Find Syntax Errors

By

Minified JSON is efficient for transport but difficult to inspect. Pretty-printed JSON is easier to review, yet it does not make invalid input valid. The useful workflow is to validate first, format a valid document for reading, and only minify the final copy when a system requires compact output.

Common JSON mistakes

JSON is stricter than JavaScript object-literal syntax. These patterns cause many parser errors:

  • a trailing comma after the last property or array item
  • single quotes around keys or strings instead of double quotes
  • an unquoted key such as name: "Ada"
  • a missing closing } or ]
  • a raw line break or unescaped quote inside a string
  • comments inside a document that is supposed to be JSON

For example, this is invalid because of the trailing comma:

{"name":"Ada","active":true,}

The valid version removes the final comma:

{"name":"Ada","active":true}

Format JSON and read the first error

  1. Open the JSON Formatter and paste the document.
  2. Watch the validation status. If it is invalid, read the reported line and column first.
  3. Fix one error at a time, starting near the reported position.
  4. Click Format with two or four spaces, or choose tabs for the indentation style you use.
  5. Use Minify only after the document validates and you have finished reviewing it.

The first reported position is often the point where the parser gave up, not the original mistake. A missing comma on the previous line can make the next property look guilty. Check the preceding delimiter, quote and closing bracket before changing the highlighted line.

Formatting does not validate your data model

Valid JSON can still have the wrong shape. A formatter can confirm that the text parses, but it cannot know whether an API requires userId instead of user_id, an array instead of an object, or a number instead of a string. After syntax validation, check the schema and required fields in the service that consumes the data.

Formatting also does not redact secrets. Access tokens, passwords and personal data remain in the output. Use a synthetic sample or remove sensitive values before sharing a formatted payload in a ticket or chat.

For large payloads, format a copy and keep the original response unchanged for comparison. If the JSON came from a CSV conversion, the CSV to JSON Converter can handle quoted commas and headers before you inspect the resulting objects. The formatter itself parses locally in your browser, so the pasted JSON is not sent to a server.

Ready to try it?

JSON Formatter & Validator — free and unlimited, right in your browser.

JSON Formatter →

← More guides