Validate JSON syntax online. Check for errors, find issues, and fix JSON formatting problems instantly.
JSON validation has three levels of depth. Syntax validation (what this tool does) checks if your JSON follows the basic grammar rules—proper quotes, commas, brackets, and data types. This is the first and most critical check. If syntax validation fails, your JSON cannot be parsed by any system.
Linting goes further by checking code style and best practices—like consistent indentation, no duplicate keys, and proper sorting. Tools like ESLint or Prettier provide linting for JSON. Schema validation is the deepest level, verifying that your JSON matches a specific structure defined in JSON Schema—ensuring required fields exist, data types are correct, and values fall within allowed ranges.
When you call JSON.parse(), JavaScript's JSON parser tokenizes the string—breaking it into keywords, strings, numbers, brackets, etc. It then builds an abstract syntax tree (AST) representing the structure. If any token violates JSON grammar rules, the parser throws a SyntaxError with position information.
Modern JavaScript engines (V8 in Chrome/Node, SpiderMonkey in Firefox) use highly optimized parsers that can process large JSON files in milliseconds. However, they're strict—where JavaScript object literals allow single quotes, trailing commas, and unquoted keys, JSON enforces stricter rules for cross-language compatibility.
1. Quotes: All strings must use double quotes ("text"), never single quotes ('text'). Property names must also be quoted strings.
2. Commas: Commas separate elements in arrays and properties in objects. No comma after the last element—trailing commas are forbidden in JSON (unlike JavaScript).
3. Brackets: Objects use curly braces {}, arrays use square brackets []. Every opening bracket must have a matching closing bracket.
4. Data Types: JSON supports six types: strings (in double quotes), numbers (no leading zeros), booleans (true/false), null, objects, and arrays. Functions, undefined, and dates are not valid JSON types.
5. Whitespace: Spaces, tabs, and newlines are allowed between tokens but not within strings or numbers.
Not all JavaScript objects are valid JSON. JavaScript is more permissive. These are valid in JavaScript but invalid in JSON:
{name: "John"}{'name': 'John'}{"name": "John",}0xFFThis is why copying JavaScript code that "looks like JSON" often fails validation. Always use JSON.stringify()to ensure valid JSON output.
Invalid JSON in production causes runtime crashes, API failures, and data corruption. When a mobile app crashes because a config file has a trailing comma, or a CI/CD pipeline fails because package.json has a syntax error, these are preventable issues that validation catches early.
Many developers assume "if my editor doesn't show errors, it's valid." But editors can be misconfigured, or you might be editing JSON in a plain text editor. Always validate JSON before committing to version control, deploying to production, or sharing with APIs. One syntax error can bring down an entire service.
According to the JSON specification (RFC 8259), trailing commas are explicitly forbidden. While JavaScript, Python, and other languages allow them for convenience, JSON's strict grammar does not. This is because JSON is a data interchange format designed for cross-language compatibility, not a programming language.
{
"name": "John",
"age": 30,
}{
"name": "John",
"age": 30
}JSON only accepts double quotes for strings and property names. This is hardcoded in the JSON spec. Single quotes, backticks, or no quotes at all will cause parsing to fail. Even if your JavaScript happily accepts single quotes, JSON parsers in Python, Java, Go, or any other language will reject it.
{'name': 'John', 'city': 'NYC'}{"name": "John", "city": "NYC"}In JavaScript, you can write {name: "John"} and it's valid. But JSON requires all property names to be quoted strings: {"name": "John"}. This is a common error when manually converting JavaScript objects to JSON.
{name: "John", age: 30}{"name": "John", "age": 30}Special characters in strings must be properly escaped. Newlines must be \\n, tabs \\t, quotes \\", and backslashes\\\\. Windows file paths are especially problematic—C:\\Users\\file.txtmust become C:\\\\Users\\\\file.txt in JSON.
{"path": "C:\Users\file.txt"}{"path": "C:\\Users\\file.txt"}JSON must be UTF-8 encoded. If you're working with files from Windows (UTF-16) or legacy systems (Latin-1), you might encounter encoding errors. Special characters like é, ñ, or 中文 should work fine in UTF-8, but can cause "unexpected character" errors if the file encoding is wrong. Always save JSON files as UTF-8 without BOM (Byte Order Mark).
JSON has strict number rules: no leading zeros (except for decimals like 0.5), no hex numbers, no NaN or Infinity. Scientific notation is allowed (1.5e10), but must be lowercase 'e'.
007 (leading zero) → Valid: 70xFF (hex) → Valid: 255NaN or Infinity → Valid: null or string representationWhile our tool validates syntax, JSON Schema validates structure. Define a schema specifying required fields, data types, value ranges, and patterns. For example, enforce that "email" must match an email regex, "age" must be 0-120, and "role" must be one of ["admin", "user", "guest"]. Libraries like Ajv (JavaScript), jsonschema (Python), and go-jsonschema implement JSON Schema validation for rigorous data verification.
Never trust client input. Even if your frontend sends valid JSON, validate it server-side. Use validation middleware like Express Validator (Node.js), Pydantic (Python), or Bean Validation (Java) to check incoming JSON. This prevents injection attacks, data corruption, and unexpected crashes from malformed requests.
Add JSON validation to your CI/CD pipeline to catch errors before deployment. Use tools like:
jq: Command-line JSON processor with validationjsonlint: CLI validator for JSON filesajv-cli: Validate against JSON SchemaConfiguration errors cause the majority of production outages. Before deploying a new config.json, validate it with this tool, then test load it in a staging environment. For critical configs (database connection strings, API keys), use automated tests that attempt to parse and use the config before allowing deployment.
Different tools for different needs:
Real-World Scenario: Your app stopped receiving webhook events from a payment provider
Step 1: Capture the Failing JSON
Check server logs or use a webhook testing tool like Webhook.site to capture the exact JSON payload being sent. Copy the raw JSON—don't trust what the logs "pretty print" as they might hide errors.
Step 2: Validate the Syntax
Paste the JSON into our validator above. If it's invalid, the validator shows exactly where the error is. Common issues: the payment provider's API might have changed and now includes trailing commas, or they're using single quotes in a new field.
Step 3: Try Auto-Fix
Click "Try Auto-Fix" to see if common issues can be corrected automatically. Our auto-fix handles trailing commas, quote issues, and basic formatting problems. If auto-fix works, you've identified the issue: your parser can't handle the provider's non-spec-compliant JSON.
Step 4: Diagnose the Root Cause
If the JSON is valid, the problem isn't syntax—it's your application logic or schema validation. If invalid, contact the API provider's support with evidence. Use this validated/fixed JSON as proof of the issue.
Step 5: Implement a Fix
Option A: If the provider won't fix invalid JSON, add preprocessing to your webhook handler to clean the JSON before parsing. Option B: Use a more permissive parser temporarily while the provider fixes their API. Option C: Switch to a different webhook endpoint if available (e.g., v2 API vs v1).
Using Browser DevTools with the Validator
When debugging web apps, check the Network tab in DevTools (F12). Look for failed API requests (red status codes). Click the request, go to "Response" tab, copy the JSON, and validate it here. Often the backend returns malformed JSON (missing closing bracket, encoding issues) that crashes your frontend's JSON.parse(). The browser just says "SyntaxError" without details—our validator pinpoints the exact error.
Common Framework-Specific Issues
JSON.parse() fails in useEffect, validate the API response first. React's error boundaries won't catch JSON parse errors in async code.v-for on API data, invalid JSON can cause the entire component to fail rendering silently. Validate JSON before setting reactive data.responseType: 'text' and validate manually.express.json() middleware throws errors on invalid JSON but doesn't always show where the error is. Validate request bodies in development.JSON validation checks if your JSON data follows the correct syntax rules. Valid JSON must have properly matched brackets, quoted strings, correct comma placement, and valid data types.
Our validator shows the exact line and column where the error occurs
Click the "Try Auto-Fix" button to automatically correct common issues
If auto-fix doesn't work, manually correct based on the error message
Click "Validate JSON" again to ensure all issues are fixed
{"name": 'John'}{"name": "John"}Master JSON validation with these comprehensive guides and tutorials from our blog:
Complete troubleshooting guide for syntax errors, validation failures, and parsing issues.
Deep dive into JSON syntax rules, error patterns, and debugging techniques.
Learn how to validate JSON structure and data types with JSON Schema.
Professional validation strategies for production systems and APIs.
Foundation knowledge about JSON syntax, structure, and rules.