What is JSON?
JSON (JavaScript Object Notation) is a lightweight data interchange format. It's easy for humans to read and write, and easy for machines to parse and generate. JSON is language-independent but uses conventions familiar to programmers of the C-family of languages.
JSON is commonly used for APIs, configuration files, and data storage. It has largely replaced XML as the preferred format for web service data exchange.
JSON Structure
JSON is built on two structures:
- Objects: A collection of key/value pairs enclosed in curly braces
{}. Keys must be strings in double quotes.
- Arrays: An ordered list of values enclosed in square brackets
[]. Values are separated by commas.
Values can be strings, numbers, booleans (true/false), null, objects, or arrays. This allows for nested data structures of arbitrary complexity.
JSON Validation Rules
- Strings must use double quotes:
"hello" is valid, 'hello' is not.
- Property names must be quoted:
{"name": "value"} not {name: "value"}.
- No trailing commas:
[1, 2, 3] is valid, [1, 2, 3,] is not.
- No comments: JSON does not support
// or /* */ comments.
- No undefined: Use
null instead of undefined.
- Numbers cannot have leading zeros:
0.5 is valid, 00.5 is not.
Using This JSON Validator
This tool helps you validate JSON online quickly and accurately:
- Validate: Checks if your JSON is syntactically correct and shows detailed error information if not.
- Format: Validates and then pretty-prints your JSON with proper indentation for readability.
- Copy: Copies the current JSON content to your clipboard.
- Clear: Clears the input area to start fresh.
When an error is found, you'll see the exact line and column number, plus a description of what went wrong. This makes debugging malformed JSON much easier.