How to validate JSON
A single stray comma can break an entire API response. This guide explains what JSON validation is, the most common syntax errors and how to fix them — all using a free tool that runs entirely in your browser.
Try the JSON ValidatorWhat is JSON?
JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging structured data. It represents two structures: collections of name/value pairs (objects) and ordered lists of values (arrays). Almost every modern API, configuration file and data interchange relies on JSON because it is compact, human-readable and language-independent.
A minimal JSON object looks like this:
{
"name": "Ada",
"active": true,
"tags": ["maths", "computing"]
}
What is a JSON Validator?
A JSON Validator checks whether your text conforms to the JSON syntax standard (RFC 8259). It parses the input using a standards-compliant parser and reports any syntax errors with the exact location where parsing failed. Validation does not modify your data — it simply confirms whether the text is valid JSON or identifies the problem so you can fix it.
To validate JSON:
- Paste your JSON into the editor or upload a
.jsonfile. - Click Validate JSON to parse it instantly.
- If valid, the tool reports the root type and lightweight statistics. If invalid, it shows the error message with the line and column where parsing failed.
Why is my JSON invalid?
The most common causes of invalid JSON are:
- Missing quotation marks — JSON property names must be enclosed in double quotes.
{name: "John"}is invalid;{"name": "John"}is valid. - Single quotes — JSON uses double quotes for all strings.
{'name': 'John'}is invalid;{"name": "John"}is valid. - Trailing commas — Standard JSON does not allow a comma after the last value in an object or array.
{"a": 1,}is invalid. - Missing commas — Values in an object or array must be separated by commas.
{"a": 1 "b": 2}is invalid. - Unclosed brackets — Every
{must have a matching}and every[must have a matching]. - Invalid values — Valid JSON values include strings, numbers, objects, arrays,
true,falseandnull. Functions,undefinedand bare dates are not valid JSON values. - Incorrect escaping — Special characters in strings must be properly escaped with a backslash (for example,
"line\\nbreak").
JSON Syntax Rules
JSON has a small, strict syntax:
- Objects are enclosed in
{ }and contain key-value pairs. - Arrays are enclosed in
[ ]and contain ordered values. - Property names must be double-quoted strings.
- String values must be double-quoted.
- Values are separated by commas.
- Valid primitive values include strings, numbers,
true,falseandnull.
JSON vs JavaScript
JSON is based on JavaScript object literal syntax but is stricter. JavaScript allows unquoted keys, single quotes, trailing commas and comments — none of which are valid in JSON.
This is a JavaScript object literal:
const user = {
name: "John",
age: 30,
};
This is valid JSON:
{
"name": "John",
"age": 30
}
The key differences: JSON requires double-quoted keys, does not allow trailing commas, does not support comments, and cannot contain expressions or functions.
What is JSON Formatting?
JSON formatting (also called pretty-printing or beautifying) adds consistent indentation and line breaks to minified JSON so the structure is visible at a glance. The data itself is not changed — only the whitespace around it. You can choose 2 spaces, 4 spaces or tabs for indentation.
What is JSON Minification?
JSON minification removes all unnecessary whitespace (spaces, tabs, newlines) to produce the smallest possible valid JSON. The underlying data is preserved exactly — only the formatting is removed. Minified JSON is ideal for production API responses and data transfer where every byte counts.
Validate JSON in your browser
Because parsing, formatting and minifying are all pure text operations, they can run entirely client-side. That means your data never leaves your device — important for privacy, speed and offline use. Try the JSON Validator to validate, format and minify JSON right now.
Try these tools
JSON Validator
Validate JSON online, find syntax errors, format and minify JSON with clear error messages and line and column information.
Use toolJSON Formatter
Format, validate and minify JSON instantly — all in your browser.
Use toolJSON to CSV Converter
Convert JSON data into a CSV spreadsheet instantly — all in your browser.
Use toolFrequently asked questions
What does a JSON validator do?+
It parses your text with a standards-compliant JSON parser and reports whether it is valid. If parsing fails, it shows the line and column of the error so you can find and fix it quickly.
Why does JSON fail with 'Unexpected token'?+
This usually means a structural error such as an unquoted key, single quotes, a trailing comma or a missing bracket. The validator reports the line and column to help you locate it.
Is validating JSON safe?+
Yes. When validation runs in your browser, your data is never uploaded. The text is parsed locally so sensitive data stays on your device.