JSON Validation Guide
Everything you need to know about JSON validation — syntax rules, linting, JSON Schema validation, and how to fix the most common errors. Whether you're a beginner or fixing a production bug, this guide covers it all.
Table of Contents
What is JSON Validation?
JSON validation is the process of checking that a piece of text is valid JSON — meaning it can be parsed without errors and, optionally, that it conforms to an expected data structure. A JSON validator (also called a JSON linter or JSON checker) performs this check automatically.
There are two distinct levels of JSON validation:
- Syntax validation — Is the JSON parseable? Does it follow RFC 8259 JSON syntax rules?
- Schema validation — Does the JSON have the correct structure, required fields, and value types?
Most developers need syntax validation daily — whenever they write JSON by hand, receive JSON from an API, or debug a JSON syntax error. Schema validation becomes important when building APIs or configuration systems where data structure must be enforced. Use the JSON Validator to run both checks instantly in your browser.
Types of JSON Validation
Syntax Validation (JSON Linting)
Verifies your JSON is parseable. Catches trailing commas, unquoted keys, single quotes, mismatched brackets, and other syntax errors.
When to use: Every time you write or receive JSON
→ JSON ValidatorJSON Schema Validation
Validates that your JSON conforms to a defined schema — correct field names, data types, required properties, and value constraints.
When to use: When you need to enforce a specific data structure (APIs, config files)
→ JSON ValidatorSemantic Validation
Application-level checks beyond syntax and schema — e.g., is this date in the future? Does this ID reference a real record?
When to use: In your application code after parsing
JSON Syntax Rules
JSON is governed by RFC 8259. These are the core rules every JSON validator enforces:
| Rule | Valid | Invalid | Note |
|---|---|---|---|
| Double-quoted strings | "hello" | 'hello' | Single quotes are not valid JSON |
| Quoted object keys | {"name": "Alice"} | {name: "Alice"} | Keys must always be in double quotes |
| No trailing commas | {"a": 1, "b": 2} | {"a": 1, "b": 2,} | Trailing commas cause parse errors |
| No comments | {"key": "value"} | {"key": "value"} // comment | JSON has no comment syntax |
| Valid value types only | "string", 42, true, null, {}, [] | undefined, NaN, Infinity | Undefined and NaN are JavaScript-only |
| Properly escaped strings | "line\nbreak" | "line break" | Special characters must be escaped |
Breaking any of these rules will cause a JSON syntax error. Use a JSON linter to catch these automatically.
How to Validate JSON Online — Step by Step
Copy your JSON
Copy the JSON text you want to validate — from your code, an API response, a config file, or anywhere else.
Paste into the JSON Validator
Open the JSON Validator and paste your JSON into the input field. The validator runs entirely in your browser — nothing is sent to a server.
Read the validation result
If your JSON is valid, you'll see a green "Valid JSON" indicator. If there's a syntax error, the validator shows the exact line number and a description of the problem.
Fix errors and re-validate
Use the error message to find and fix the problem. Check the JSON Errors Guide for before/after fix examples for every common error. Then paste again and re-validate.
JSON Schema Validation
JSON Schema is a vocabulary that lets you annotate and validate JSON documents. It goes beyond syntax checking to enforce structure: required fields, data types, value ranges, and more. JSON Schema validation is widely used in REST APIs (via OpenAPI) and configuration systems.
A simple JSON Schema looks like this:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["name", "age"],
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 },
"email": { "type": "string", "format": "email" }
}
}This schema would validate that a JSON object has a name string and an age integer, and reject anything that doesn't match. JSON Schema validation is what powers API contract testing and data pipeline validation at scale.
Common JSON Validation Errors
These are the JSON syntax errors that trip up even experienced developers. For the full list with before/after fixes, see the JSON Errors Guide.
errorTrailing comma
{"a": 1,}Remove the last comma before } or ]
errorSingle quotes
{'key': 'value'}Use double quotes for all strings and keys
errorUnquoted keys
{name: "Alice"}Wrap every key in double quotes
errorComments
{"k": 1} // noteRemove all comments — JSON has no comment syntax
errorUndefined value
{"x": undefined}Use null instead of undefined
errorMissing quotes
{"name": Alice}All string values must be in double quotes
JSON Validation Tools
JSON Validator
Validate JSON syntax instantly. Catches every RFC 8259 error.
JSON Formatter
Format and validate JSON. Beautify with indentation.
JSON Errors Guide
Every common JSON error with before/after fix examples.
JSON Viewer
Browse JSON as a collapsible tree. Spot structural problems visually.
FAQ – JSON Validation
What are the JSON validation rules?expand_more
JSON validation rules include: all strings must use double quotes, object keys must be strings in double quotes, no trailing commas are allowed, values must be one of: string, number, boolean, null, array, or object, and no comments are permitted in JSON.
What is the difference between JSON linting and JSON Schema validation?expand_more
JSON linting checks that your JSON is syntactically correct — it will catch trailing commas, unquoted keys, and single quotes. JSON Schema validation goes further: it checks that your JSON has the correct structure, data types, and required fields as defined by a schema document.
How do I validate JSON syntax online?expand_more
Paste your JSON into a JSON validator tool like the one at openformatter.com/json-validator. The tool will instantly parse your JSON and report any syntax errors with the line number and a description of the problem.
Can JSON have comments?expand_more
No. Standard JSON (RFC 8259) does not allow comments. If you need comments, consider JSON5 or JSONC formats, or strip comments before parsing. JSON was intentionally designed without comments to keep parsers simple.
Part of the JSON Toolkit
Explore All JSON Tools
Free online tools for every JSON task — format, validate, convert, compare, and more.