JSON Formatter and Validator

Paste JSON to check that it is valid, make it readable with indentation, or compress it into a single line. Errors are shown with their line and column.

—

Result


JSON syntax rules and how to fix errors

JSON (JavaScript Object Notation) is the most common format for exchanging data between web services. It has only six kinds of values: objects in curly braces with "key": value pairs, arrays in square brackets, strings in double quotes, numbers, true or false, and null. Everything else, including comments and trailing commas, is invalid.

Most errors come from writing JSON by hand or copying it from JavaScript code. Keys must be in double quotes: {"name": "Ana"} is valid, while {name: "Ana"} and {'name': 'Ana'} are not. The last item of an object or array cannot be followed by a comma. Numbers cannot have leading zeros (007) or a trailing dot, and the words true, false and null must be lowercase.

When the JSON is invalid, the validator shows the browser's error message and, when it can, the line and column where parsing stopped. The real mistake is often just before that point, for example a missing comma at the end of the previous line or an unclosed quote further up.

Formatting with two or four spaces makes nested data easy to read and compare; minifying removes every unnecessary space to make the file smaller, which is useful before sending it in a request or storing it. Sorting keys puts object properties in alphabetical order, which helps when comparing two versions of the same JSON.

How to use it

  1. Paste your JSON in the box.
  2. Press Format to indent it or Minify to remove the spaces. Tick "Sort keys" to order object keys alphabetically.
  3. Copy or download the result. If the JSON is invalid, the message shows where the error is.

Frequently asked questions

Is my JSON sent to a server?

No. Parsing and formatting use your browser's built-in JSON engine, so API keys, tokens or customer data in your JSON never leave your device.

What are the most common JSON errors?

A comma after the last item, single quotes instead of double quotes, keys without quotes, comments, and values such as undefined or NaN. All of these are valid in JavaScript but not in JSON.

Does formatting change my data?

No. Formatting only adds or removes whitespace between values. Sorting keys changes the order of object properties, which does not change the meaning of JSON, but the order of array items is always kept.

More free tools