JSON Validator Online

Paste any JSON to instantly check its syntax, identify errors by line number, and format it for readability. Free, private, no signup required.

What is JSON Validation?

JSON validation is the process of checking that a piece of text conforms to the JSON specification (ECMA-404 / RFC 8259). Valid JSON must follow strict rules about syntax: keys must be double-quoted strings, values must be one of six types (string, number, boolean, null, array, or object), arrays and objects must be properly closed, and trailing commas are not permitted.

JSON validation is one of the most frequent tasks in everyday API development. You need it when:

The JSON validator on JSON Web Tools highlights the exact line and column where a syntax error was detected, making it fast to locate and fix problems even in large JSON documents.

Common JSON Errors and How to Fix Them

Trailing comma

This is the most frequent JSON error. Standard JSON does not allow a comma after the last element in an object or array. Many developers coming from JavaScript (which allows trailing commas) make this mistake.

// Invalid JSON
{ "name": "Alice", "age": 30, }

// Valid JSON
{ "name": "Alice", "age": 30 }

Single quotes instead of double quotes

JSON requires double quotes for both keys and string values. Single quotes are JavaScript syntax, not JSON syntax.

// Invalid JSON
{ 'name': 'Alice' }

// Valid JSON
{ "name": "Alice" }

Unquoted keys

In JavaScript object literals, keys can be unquoted. In JSON, all keys must be quoted strings.

// Invalid JSON
{ name: "Alice" }

// Valid JSON
{ "name": "Alice" }

Comments in JSON

JSON does not have a comment syntax. Comments that work in JavaScript (// ... or /* ... */) will cause a parse error in JSON. If you need comments in configuration files, use JSONC (JSON with Comments) format and a parser that supports it.

Undefined, NaN, and Infinity

These are JavaScript values that have no JSON equivalent. undefined, NaN, and Infinity in a JSON string will cause a validation failure. Use null or a sentinel numeric value instead.

Missing comma between elements

Every element in an array and every key-value pair in an object (except the last one) must be followed by a comma.

// Invalid JSON
{ "name": "Alice" "age": 30 }

// Valid JSON
{ "name": "Alice", "age": 30 }

How to Use the JSON Validator

  1. Click "Open JSON Validator" above.
  2. Paste your JSON into the input field. The tool validates as you type.
  3. If the JSON is valid, you will see a green confirmation and the formatted output.
  4. If there is an error, the problematic line is highlighted and the error message explains the issue.
  5. Fix the error, re-paste, and validate again until the JSON is clean.
  6. Copy the formatted JSON output for use in your project.

The validator also prettifies your JSON - adding consistent indentation and line breaks - which makes large, minified JSON documents much easier to read and debug.

Frequently Asked Questions

How do I validate JSON online?+
Paste your JSON into the validator above and click Validate. The tool instantly checks your JSON for syntax errors and shows the exact line and column of any problem with a clear error message.
What are the most common JSON errors?+
The most common JSON errors are: trailing commas after the last item (not allowed in JSON), single quotes instead of double quotes, unquoted property keys, missing commas between items, JavaScript-style comments (// or /* */), and using undefined, NaN, or Infinity values.
What is the difference between JSON syntax validation and schema validation?+
Syntax validation checks if the JSON is well-formed and parseable. Schema validation checks if the parsed JSON matches an expected structure — correct field names, types, and constraints. Use the JSON Schema Validator for structure validation.
Can I validate JSON from a URL or file?+
Yes. You can paste JSON text, upload a .json file, or fetch JSON from a URL. All processing happens in your browser — the URL fetch is also client-side using the Fetch API.
Does JSON allow trailing commas?+
No. Standard JSON does not allow trailing commas — this is one of the most common sources of invalid JSON. Some tools support JSONC (JSON with Comments) which allows trailing commas, but strict JSON parsers like JSON.parse() will reject them.
What JSON standard does this tool use?+
This tool validates against the official JSON specification defined in RFC 8259 and ECMA-404. It uses the browser's native JSON.parse() under the hood, which is fast and fully spec-compliant.

Ready to validate your JSON?

Free, instant, 100% private. No account needed.

Common JSON Validation Errors

JSON is strict about syntax. A single misplaced comma, missing quote, or wrong data type will cause the entire document to be invalid. The validator catches these errors instantly.

Valid vs Invalid JSON Examples

// INVALID — trailing comma
{"name": "Alice", "age": 30,}

// INVALID — single quotes
{'name': 'Alice'}

// INVALID — unquoted key
{name: "Alice"}

// INVALID — comment
{"name": "Alice" /* user */}

// VALID
{"name": "Alice", "age": 30}

Common Validation Errors Reference

Error TypeExampleFix
Trailing comma{"a":1,}Remove the last comma
Single quotes{'a':'b'}Use double quotes
Unquoted key{a: 1}Wrap key in double quotes
Undefined value{"a": undefined}Use null instead
Missing comma{"a":1 "b":2}Add comma between pairs
Extra bracket{"a":1}}Balance all brackets
NaN/Infinity{"x": NaN}Use null or a number string
JS comment{"a":1 // note}Remove comments (not valid JSON)

JSON vs JavaScript Object Literals

  • JSON keys must always be double-quoted strings
  • JSON does not allow trailing commas
  • JSON values can only be: string, number, object, array, true, false, null
  • JSON does not support undefined, NaN, Infinity, or comments
  • JSON dates are strings (ISO 8601) — not native Date objects

Also useful: JSON Repair Tool | CSV to JSON Converter | JWT Decoder | JSON Guides

The 10 Most Common JSON Errors (and How to Fix Them)

JSON syntax is strict. Even a single misplaced character will cause a parse failure. Here are the 10 errors that account for the vast majority of invalid JSON in the wild — each with a before-and-after example.

  1. Trailing comma{"a":1,}{"a":1} — Remove the comma after the last element
  2. Single quotes{'key':'val'}{"key":"val"} — JSON requires double quotes everywhere
  3. Unquoted key{name:"Alice"}{"name":"Alice"} — All keys must be quoted strings
  4. undefined value{"x":undefined}{"x":null}undefined is a JavaScript concept; use null
  5. Missing comma between pairs{"a":1 "b":2}{"a":1,"b":2} — Each key-value pair must be comma-separated
  6. Comments in JSON{"a":1 // note}{"a":1} — Comments are not valid JSON; remove them entirely
  7. NaN or Infinity{"x":NaN}{"x":null} — Use null or a numeric string instead
  8. Unescaped special character{"msg":"say "hi""}{"msg":"say \"hi\""} — Escape double quotes inside strings with \"
  9. Control character in string — A raw tab or newline inside a string value is invalid. Use \t or \n escape sequences instead
  10. Trailing text after root{"a":1} extra{"a":1} — JSON must have exactly one root value with nothing after it

JSON Validation in Different Languages

Every major language has a built-in or standard-library way to validate JSON. Here is the idiomatic pattern in each:

JavaScript

function isValidJSON(str) {
  try {
    JSON.parse(str);
    return true;
  } catch (e) {
    return false;
  }
}

// With error detail
function validateJSON(str) {
  try {
    const parsed = JSON.parse(str);
    return { valid: true, data: parsed };
  } catch (e) {
    return { valid: false, error: e.message };
  }
}

Python

import json

def validate_json(text):
    try:
        data = json.loads(text)
        return True, data, None
    except json.JSONDecodeError as e:
        return False, None, str(e)

valid, data, err = validate_json('{"name": "Alice"}')
print(valid)   # True

PHP

<?php
function isValidJSON(string $str): bool {
    json_decode($str);
    return json_last_error() === JSON_ERROR_NONE;
}

// PHP 8.3+: json_validate() built-in
$valid = json_validate('{"name": "Alice"}'); // true

Bash (jq)

# Returns exit code 0 for valid, non-zero for invalid
echo '{"name":"Alice"}' | jq . > /dev/null 2>&1
if [ $? -eq 0 ]; then echo "Valid JSON"; else echo "Invalid JSON"; fi

# Validate a file
jq . myfile.json > /dev/null 2>&1 && echo "Valid" || echo "Invalid"

Go

package main

import (
    "encoding/json"
    "fmt"
)

func isValidJSON(s string) bool {
    var js json.RawMessage
    return json.Unmarshal([]byte(s), &js) == nil
}

func main() {
    fmt.Println(isValidJSON(`{"name":"Alice"}`)) // true
    fmt.Println(isValidJSON(`{name:"Alice"}`))   // false
}

JSON Validator vs JSON Schema Validator

There are two distinct types of JSON validation. A basic JSON validator checks syntax — is this valid JSON? A JSON Schema validator checks structure and semantics — does this JSON match a defined shape? Understanding the difference helps you choose the right tool for the job.

FeatureJSON ValidatorJSON Schema Validator
What it checksSyntax only — is this valid JSON?Structure, types, required fields, value constraints
Input neededJust the JSON stringJSON string + a JSON Schema definition
Error messagesSyntax error at line/column"field 'age' must be a number", "missing required property 'email'"
Use caseDebugging malformed JSON; quick sanity checkAPI contract validation; config file validation; CI/CD checks
SpeedVery fast — single parse passSlower — walks the entire document against the schema
Example error"Unexpected token } at position 12""$.user.age: must be >= 0"

In practice, you need both: run a JSON validator first to ensure parseable JSON, then run a schema validator to ensure the data matches your application's expected shape. This tool handles the first step — see our JSON Schema Tutorial for the second.