Skip to main content
CalcHive

JSON Validator

Examples

Valid JSON object

In:{"name": "Alice", "age": 30, "languages": ["JavaScript", ...

Invalid JSON (missing comma)

In:{"name": "Alice" "age": 30}

Nested valid JSON

In:{"server": {"host": "localhost", "port": 8080}, "debug": ...
Share:

Validate JSON syntax instantly with detailed error messages showing the exact line and position of errors. Format valid JSON with indentation.

How to Use JSON Validator

  1. Paste or type your JSON into the input area.
  2. Click "Validate" or use an example to test.
  3. If the JSON is valid, the formatted output appears on the right.
  4. If invalid, an error message shows the line and position of the issue.
  5. Click "Copy" to copy the formatted result.

What is JSON Validation?

JSON validation is the process of checking whether a string conforms to the JSON (JavaScript Object Notation) specification defined in RFC 8259. JSON is the most widely used data interchange format on the web, powering REST APIs, configuration files, NoSQL databases, and message queues. Valid JSON requires strict syntax: all strings must use double quotes, no trailing commas are permitted, keys must be quoted, and all brackets and braces must be properly matched and nested. This tool parses your input and reports the exact location and nature of any syntax errors.

How JSON Validation Works

The validator uses the built-in JSON.parse() function to attempt to parse your input. If parsing succeeds, the JSON is valid and the tool displays a formatted version with proper indentation. If parsing fails, the JavaScript engine throws a SyntaxError with a message indicating what went wrong and approximately where the error occurred. Common error messages include "Unexpected token," "Unexpected end of JSON input," and "Expected property name or closing brace." The validator displays this information so you can quickly locate and fix the problem.

Common Use Cases

  • Debugging API responses that cause parsing errors in your application
  • Verifying configuration files before deployment
  • Checking JSON payloads before sending them in HTTP requests
  • Validating data exports from databases and analytics tools
  • Troubleshooting webhook payloads and event data
  • Checking JSON files generated by build tools and code generators

Common JSON Syntax Errors

The most frequent JSON syntax errors are easily avoided once you know the rules. Trailing commas after the last element in an array or object are the most common mistake; languages like JavaScript allow them, but JSON does not. Single-quoted strings ('hello') are invalid; JSON requires double quotes ("hello"). Unquoted keys ({name: "value"}) are valid JavaScript but invalid JSON. Comments, whether // or /* */, are not permitted in JSON. Multiline strings are not supported; use \n for line breaks.

Other subtle issues include using undefined or NaN as values (both are invalid in JSON), having duplicate keys (technically allowed by the spec but may cause unexpected behavior), and including a BOM (byte order mark) at the start of the file. If you are copying JSON from a JavaScript file, be careful to strip out any JS-specific syntax. Some editors and APIs produce "JSON with comments" (JSONC), which is not standard JSON and will fail strict validation.

For beautifying valid JSON, use our JSON Formatter. You can convert JSON to other formats with the JSON to YAML Converter, or generate TypeScript types from your data using JSON to TypeScript.

Frequently Asked Questions

Related Tools

Was this tool helpful?