JSON

JSON Validator

Paste JSON to check that it is valid. If it is not, you get the line, column and a pointer to the problem. Valid documents also get size and structure statistics.

Guide: JSON Syntax Error: Fix 'Unexpected Token' and Invalid JSON

Ready. Paste JSON to validate it.

What it does

The validator parses your text with the same strict JSON rules used by web browsers and APIs. Typical mistakes it catches include trailing commas, single quotes, unquoted keys, comments and missing brackets.

Reading the result

  • An invalid document shows the line and column, plus the offending line with a caret under the problem.
  • A valid document shows its root type, size, number of values and keys, and how deeply it is nested.
  • Duplicate keys are legal to parse but usually a mistake, so they are reported as a warning.

Tip

Error positions come from your browser's JSON parser, so the wording can differ slightly between Chrome, Firefox and Safari. To reformat a valid document, use the JSON Formatter.

Common JSON errors and how to fix them

These are the messages this validator shows for the mistakes people make most often. Line and column both start at 1.

  • Trailing comma. {"a":1,} gives “Invalid JSON at line 1, column 8: Expected a double-quoted property name but found '}'.” Remove the comma after the last item.
  • Single quotes. {'a':1} gives “…Expected a double-quoted property name but found '''.” JSON allows only double quotes around keys and strings.
  • Unquoted key. {a:1} gives “…Expected a double-quoted property name but found 'a'.” Write {"a":1}.
  • Missing comma. {"a":1 "b":2} gives “…Expected ',' or '}' but found '"'.” Add a comma between the members.
  • Leading zero. {"a":01} gives “…Expected ',' or '}' but found '1'.” JSON numbers cannot start with 0 unless the value is 0 itself, so write 1, or use a string such as "01".
  • NaN, Infinity or undefined. {"a":NaN} gives “…Unexpected 'N' where a value was expected.” None of these exist in JSON. Use null or a string.
  • Comments. {"a":1} // note gives “…Unexpected '/' after the end of the JSON value.” JSON has no comments. Files such as tsconfig.json and VS Code settings use JSON with comments (JSONC), so remove the comments before you validate them as plain JSON.
  • Raw line break in a string. A real newline inside quotes gives “Unescaped control character in a string.” Write it as \n.

Valid JSON compared with a JavaScript object

A JavaScript object literal is more relaxed than JSON. JSON requires double-quoted keys and strings, allows no comments or trailing commas, and has only the values string, number, true, false, null, object and array. A value that works in your code may therefore still fail here, which is exactly why you validate before you send it to an API or save it as a config file.

Frequently asked questions

Is a plain string or number valid JSON?

Yes. The current standard, RFC 8259, allows any JSON value at the top level, not only an object or an array.

Why does my package.json or config file fail?

Check for comments, trailing commas and single quotes. If the file is meant to be JSON with comments, strip them first, or use the JSON Repair tool.

How do I check that the structure is right, not only the syntax?

Use the JSON Schema Validator to test the document against a schema, with the path of every error.

Can I make a long document easier to read?

Yes. Validate it here, then format it with the JSON Formatter or explore it in the JSON Tree Viewer.

Is my JSON sent to a server?

No. Validation runs in your browser.

Privacy

This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.

Share this tool

Your data is not included in this link.