JSON Validator
Validate JSON data online. Check if your JSON is syntactically correct with detailed error messages including line and column numbers.
What Is a JSON Validator?
A JSON validator checks whether a string conforms to the JSON specification defined in RFC 8259. It examines the syntax of your input — quotes, brackets, commas, data types — and reports whether the document is valid JSON or contains errors. When errors are found, the validator provides precise location information (line number, column number, and a description of the problem) so you can quickly identify and fix the issue.
JSON validation is a critical first step before formatting, parsing, or processing JSON data. Invalid JSON will cause failures in API clients, configuration loaders, database imports, and any other system that expects well-formed JSON. Catching syntax errors early saves debugging time and prevents downstream failures.
How It Works
Our validator uses the browser's native JSON.parse() method to test your input. This is the same parser used by JavaScript engines worldwide and is fully compliant with the JSON specification. If JSON.parse() succeeds, your JSON is valid. If it throws an error, the validator catches the exception, extracts the error message and position, and translates the character offset into human-readable line and column numbers.
The validation process checks for all standard JSON syntax requirements:
- Object keys must be double-quoted strings
- String values must use double quotes (not single quotes)
- No trailing commas after the last element in arrays or objects
- Numbers must follow the JSON number format (no leading zeros, no
NaN, noInfinity) - Only the values
true,false, andnullare valid literals (notundefined,True,None) - Brackets and braces must be properly matched and nested
- Unicode escape sequences must be valid
All processing happens client-side. Your data never leaves your browser.
Common Use Cases
1. Validating API Request Bodies
Before sending a JSON payload to an API endpoint, validate it to catch syntax errors. A trailing comma or an unquoted key will cause the API to reject your request with a cryptic 400 error. Validating locally first gives you a clear, immediate error message.
2. Checking Configuration Files
JSON configuration files (tsconfig.json, package.json, .eslintrc.json) are edited frequently and a single syntax error can break your build, your linter, or your deployment pipeline. Paste the file contents into the validator before saving to catch errors early.
3. Validating API Responses
If you are building an API and testing responses manually, validate the output to ensure it is well-formed JSON. Some server-side frameworks can produce invalid JSON when string concatenation is used instead of proper serialization.
4. Debugging Webhook Payloads
Webhook payloads from third-party services sometimes arrive with encoding issues or truncated content. Validating the raw payload helps you determine whether the issue is in the sending service or in your processing code.
5. Preparing Data for Import
Before importing JSON data into a database, NoSQL store, or data pipeline, validate it to ensure the import will not fail midway through. This is especially important for large files where a late-stage failure wastes significant time.
Tips and Best Practices
- Validate before you format. Formatting requires valid JSON. If your input has errors, run the validator first to identify them, fix them, and then format the corrected output.
- Use validation in CI/CD. Add a JSON validation step to your build pipeline. A simple
node -e "JSON.parse(require('fs').readFileSync('config.json'))"will catch syntax errors before deployment. - Understand what validation does and does not check. Syntax validation confirms that the JSON is well-formed. It does not check whether the data is correct, complete, or matches a schema. For semantic validation, use a JSON Schema validator.
- Watch for encoding issues. If your JSON contains non-ASCII characters, ensure the file is saved as UTF-8. Byte order marks (BOM) and encoding mismatches can introduce invisible characters that break parsing.
- Check for common mistakes. The most frequent JSON errors are trailing commas, single-quoted strings, and unquoted keys. When the validator reports an error, check these first.
FAQ
What counts as valid JSON?
Valid JSON must follow the specification (RFC 8259): double-quoted keys and strings, no trailing commas, proper data types (string, number, boolean, null, array, object), no comments, and no JavaScript-specific values like undefined or NaN.
Does it validate against a JSON Schema?
No. This tool checks JSON syntax validity only — whether the document is well-formed according to the JSON specification. For schema validation (checking that required fields are present, types are correct, values are within range), use a dedicated JSON Schema validator.
Can I validate JSON from a file?
Currently, paste your JSON directly into the input field. For validating large files from the command line, you can use node -e "JSON.parse(require('fs').readFileSync('file.json'))" or python -m json.tool < file.json.
Is my data sent to a server?
No. All validation runs entirely in your browser using JavaScript. Your JSON data is never transmitted over the network.
What if the validator says my JSON is valid but my code still fails?
Syntax validation confirms the JSON is well-formed, not that it contains the right data. If your code fails after successful validation, the issue is likely semantic — a missing field, wrong data type, or unexpected value. Check your application logic and consider using JSON Schema validation.
Why does it say "Unexpected token" with a position number?
The position number is the character offset where the parser encountered the error. The validator converts this to a line and column number for easier debugging. The error is usually at or just before the reported position — check for missing commas, quotes, or brackets.
Can it validate JSON with comments?
No. Standard JSON does not support comments. If your input contains // or /* */ comments, the validator will report them as errors. Remove comments before validation, or use a JSONC-aware parser if your toolchain supports JSON with Comments.