JSON Validator and Formatter

Paste JSON to find out at once whether it is valid. If it is not, you get the line and column of the first problem and a plain description, such as a missing comma or a trailing comma before a closing bracket. Valid JSON can be formatted with 2 spaces, 4 spaces or tabs, or minified to save space. Keys, numbers and strings are kept exactly as you wrote them. Your data never leaves the browser.

Inputs

Result

Result
Valid JSON: an object with 5 keys
Formatted JSON
{
  "name": "Online Tool Spot",
  "tools": [
    "base64",
    "url",
    "json"
  ],
  "free": true,
  "version": 1.0,
  "owner": null
}
Values
9
Deepest nesting level
2

How it is calculated

  1. Result: start from the json, then check the JSON against RFC 8259 and name its top-level type
  2. Formatted JSON: start from the json, then check the JSON and lay it out one value per line, indented with 2 spaces per level, keeping keys, numbers and strings exactly as written
  3. Values: start from the json, then count every value, including each object and array
  4. Deepest nesting level: start from the json, then count the deepest level of nesting (a plain value is 0)

Resources for your next step

Helpful downloads

View all developer & web downloads
Store coming soon

We are preparing practical spreadsheets, planners, and guides. Explore the store page for what is next.

What counts as valid JSON

The checker follows RFC 8259, the JSON standard. A document is one value: an object in curly braces, an array in square brackets, a string in double quotes, a number, true, false or null. Object keys must be strings in double quotes, and items are separated by commas with no comma after the last one.

Several things that JavaScript accepts are not JSON: single quotes, unquoted keys, trailing commas, comments, NaN and Infinity, numbers with a leading zero such as 01, and a bare decimal point such as 1. or .5. Inside a string, a real tab or line break must be written as \t or \n. Each of these is reported with its position.

Reading the error message

Lines and columns count from 1, the way code editors number them, and a column counts characters as you see them, so an emoji is one column. The message names what the parser expected at that point and what it found instead, for example "Line 3, column 3: expected a comma (,) or } after the value, but found a quote mark". The real mistake is often just before that spot, such as a missing comma at the end of the previous line.

Only the first error is shown, because one mistake can make everything after it look wrong. Fix it and the next one, if any, appears.

Formatting without changing your data

Many formatters parse JSON into a program's objects and print it again, which can quietly reorder keys that look like numbers, merge duplicate keys, and round large numbers such as 12345678901234567890. This tool re-prints every key, number and string exactly as written and only changes the spaces and line breaks between them, so the formatted result means exactly the same thing.

The example object has 5 keys and 9 values in all, counting the object and the array themselves, and its deepest value sits 2 levels down, inside the array. Minifying it removes the spaces after the colons and commas, saving 11 bytes. Minified JSON is what you send over a network; formatted JSON is what you read.

Frequently asked questions

Why does it say my JSON has a trailing comma?

JSON does not allow a comma after the last item in an object or array, even though JavaScript does. Delete the comma before the closing } or ].

Can JSON contain comments?

No. Standard JSON has no comment syntax, so // and /* */ are reported as errors. Some tools accept JSON with comments (JSONC), but it is not valid JSON.

Does formatting change the order of my keys?

No. Keys stay in the order you wrote them, duplicate keys are kept, and numbers and strings are copied character for character.

Why are single quotes an error?

JSON requires double quotes around every string and key. Replace each ' with " around the text.

What do values and nesting level mean?

Values counts every value in the document, including each object and array. Nesting level is how deep the deepest value sits: a plain number is level 0 and the items of a top-level array or object are level 1.

Is there a size limit?

You can paste up to 200,000 characters, and nesting deeper than 1,000 levels is refused to keep your browser responsive.

Sources

JSON is processed in your browser and never sent anywhere. Validation checks syntax only, not whether the data fits a particular schema.

All developer & web tools