How to Format and Validate JSON

Last updated

JSON is a text format for structured data. Formatting adds indentation so it is easier to read; validation checks that the text follows JSON syntax. A formatter cannot infer what your application expects the data to mean.

Open JSON Formatter

Steps

  1. Paste or type JSON into the JSON Formatter, or check it with JSON Validator.
  2. Run the formatter or validator and read the reported line and column if parsing fails.
  3. Fix the input, then format it again.
  4. Use JSON Visualizer if you want to expand nested objects and arrays as a tree.

Common JSON syntax mistakes

Property names and text values need double quotes. JSON does not allow comments, trailing commas, undefined, or single-quoted strings. Numbers, true, false and null are written without quotes.

A missing comma or bracket can make the parser report an error later than the actual typo. Check the line above the highlighted location as well.

Formatting does not validate your data model

Valid JSON can still have the wrong field names, types or values for a particular API. Compare the result with that service's schema or documentation after syntax validation.

The site tools process pasted data in the browser. Avoid sharing credentials or personal information in public screenshots or copied examples even when using local tools.

Common questions

Does JSON support comments?

Standard JSON does not. Remove comments before validating it.

Can a formatter repair invalid JSON automatically?

It can only format valid input. Fix syntax errors first, then format.

Is JSON the same as JavaScript object syntax?

No. JSON is stricter: keys and strings require double quotes, and executable expressions are not allowed.

Tools mentioned