Online JSON Validator
Check whether your JSON is valid and find the exact line and column of any error. The JSON validator follows the official JSON standard, so it catches trailing commas, single quotes, unquoted keys, comments and missing brackets, and shows valid JSON as a tree you can explore.
How to validate JSON
- Paste your JSON into the left editor, or open or drop a .json file.
- Press Validate or Ctrl+Enter. With Live on, the JSON is checked as you type.
- If the JSON is valid, the status line turns green and shows its type, number of keys and size, and the right editor shows it as a tree.
- If it is invalid, the status line shows the line, the column and the reason, and the editor marks the line. Fix it and the check runs again.
JSON syntax rules
The validator checks your text against the JSON standard (RFC 8259). Valid JSON follows these rules:
- The document is one value: usually an object
{ }or an array[ ]. - Object keys are strings in double quotes:
{"name": "Ada"}. - Strings use double quotes. Quotes and backslashes inside a string are escaped:
"say \"hi\"". - Items are separated by commas, with no comma after the last item.
- Numbers are plain decimals such as
42,-3.5or1e6. No leading zeros, noNaNorInfinity. - The only literals are
true,falseandnull, in lower case. - Comments are not allowed.
Common JSON errors and how to fix them
Trailing comma
{"a": 1, "b": 2,} fails because of the comma before the closing brace. Remove it. JavaScript allows trailing commas, JSON does not.
Single quotes
{'a': 'b'} fails because JSON only accepts double quotes. Replace them: {"a": "b"}.
Unquoted keys
{name: "Ada"} is a valid JavaScript object but not valid JSON. Quote the key: {"name": "Ada"}.
Missing comma or bracket
A missing comma between two items, or a bracket that is never closed, is reported at the point where the parser got confused, which is often the line after the real mistake. Look at the line above the reported one too.
Comments
// like this or /* this */ are common in config files but are not part of JSON. Remove them, or use JSON Repair to strip them.
Python or JavaScript values
True, False, None and undefined are not JSON. Use true, false and null.
Unescaped characters in strings
A real line break or tab inside a string is invalid. Write \n and \t instead. The JSON Escape tool does this for you.
Understanding error messages
Browsers word parse errors in slightly different ways, but they mean the same few things:
- "Unexpected token" or "Unexpected character": something appears where it is not allowed, often a quote, a comma or a letter.
- "Expected double-quoted property name": a key is missing its quotes, uses single quotes, or there is a trailing comma before
}. - "Unexpected end of JSON input": the text stops before every bracket and brace is closed, often because it was cut off.
- "Bad control character in string literal": a string contains a raw line break or tab.
Fix errors automatically
When the JSON came from JavaScript code, a log line, a Python print or an AI chatbot, the errors are usually the predictable kind. JSON Repair fixes trailing commas, quotes, unquoted keys, comments, Python constants and cut-off endings in one step, and gives you valid JSON back. If the input is a JSON document stored as a string, with \" everywhere, the JSON Parser decodes it.
Validate JSON in code
- JavaScript: wrap
JSON.parse(text)intry/catch. The error message names the position. - Python:
json.loads(text)raisesjson.JSONDecodeErrorwithlinenoandcolno. - Command line:
jq empty file.jsonprints nothing for valid JSON and an error with the line number otherwise.
Valid JSON is not always the right JSON
This validator checks syntax: whether a parser can read the document. It does not check that required fields are present or that values have the right type. That is the job of a JSON Schema, and schema validation is on our list of upcoming tools. To see how two valid documents differ, use JSON Compare.
A private JSONLint alternative
Like JSONLint, this JSON validator follows the standard strictly and points to the exact error. It also formats the result, shows it as a tree, lets you save and share it, and runs entirely in your browser, so nothing you validate is sent to a server. It is free, with no sign-up and no limits.