JSON Validator

Validate JSON payloads instantly in your browser to catch syntax errors.

Quick examples:

Waiting for input

Paste JSON below to validate it locally.

Editor
Loading Editor...

JSON error example library

Verified malformed JSON samples with corrected versions.

21 of 21 examples

Trailing comma in an object

Strict JSON does not allow a comma after the final property.

Trailing comma in an array

The final array item must be followed by ] rather than a comma.

Missing comma between properties

Object members must be separated by commas.

Unquoted property name

JSON requires every object property name to be a double-quoted string.

Single quotes instead of double quotes

Single-quoted strings are valid in some JavaScript contexts but not in JSON.

Unescaped quote inside a string

Literal double quotes inside a JSON string must be escaped with a backslash.

Unescaped control character

A JSON string cannot contain a raw newline; use the escaped sequence \n.

Missing closing brace

Every opening object brace must have a matching closing brace.

Missing closing bracket

The array must close with ] before the containing object closes.

Mismatched brackets

JSON arrays use square brackets and objects use curly braces.

Invalid leading zero

JSON numbers cannot use leading zeroes unless the number is exactly 0.

Plus sign in a number

JSON permits a minus sign but not a leading plus sign.

Invalid escape sequence

JSON only recognizes specific escapes; an unknown escape such as \q is invalid.

Comment inside JSON

Standard JSON has no comment syntax. Use documentation outside the JSON document.

Undefined value

JSON supports null, but not JavaScript's undefined value.

NaN value

NaN is a JavaScript number value, not a valid JSON literal.

Infinity value

Infinity is not one of JSON's permitted literal values.

Incorrect nesting

A property must have one JSON value; multiple values require an array.

Extra characters after valid JSON

A JSON document must contain one complete value and nothing else after it.

Empty input

An empty string is not a JSON document. Use null, an object, or an array when an empty value is needed.

Incorrect literal capitalization

JSON literals are lowercase: true, false, and null.

Features

  • Instant Real-Time Validation: Parses and validates your JSON syntax as you type or paste without clicking submit.
  • Pinpoint Line & Column Diagnostics: Identifies the exact character index, line number, and column where the parser failed.
  • Interactive 20-Error Library: Browse and test 20 verified real-world malformed JSON examples with one-click corrections and explanations.
  • 100% Client-Side Privacy: Runs entirely within your browser's native JavaScript engine. No proprietary data is ever sent across the network.
  • One-Click Workflow: Seamlessly copy validated JSON or move directly into the JSON Formatter for 2-space indentation.
  • Complete Format Ecosystem: Convert valid JSON directly to YAML, CSV, or XML.

How it works

This online JSON validator evaluates your input against strict RFC 8259 syntax specifications. Valid payloads display an immediate green confirmation; malformed inputs reveal the underlying parser error message along with the estimated line number and character offset.

  1. Paste or type your JSON into the validation canvas.
  2. Inspect the real-time status banner. If invalid, review the highlighted line position.
  3. Explore the curated JSON Error Example Library below to test and compare common syntax mistakes against valid corrected code.

The Top 5 JSON Syntax Traps (And How to Fix Them)

Standard JSON (RFC 8259) is stricter than JavaScript object literals. Here are the most common syntax errors developers encounter:

1. Trailing Commas in Objects or Arrays

Commas are separators, not terminators. Placing a comma after the last property is illegal.

❌ Invalid: { "name": "Alice", "age": 30, }
✅ Correct: { "name": "Alice", "age": 30 }

2. Single Quotes Instead of Double Quotes

JSON keys and string values must strictly use ASCII double quotes (").

❌ Invalid: { 'user': 'Alice' }
✅ Correct: { "user": "Alice" }

3. Unquoted Object Keys

In JavaScript, keys can omit quotes. In JSON, every object key must be a double-quoted string.

❌ Invalid: { id: 101, status: "active" }
✅ Correct: { "id": 101, "status": "active" }

4. Unescaped Characters and Raw Line Breaks

Raw newlines and backslashes inside string values must be escaped with \\n and \\\\.

❌ Invalid: "path": "C:\Users\data"
✅ Correct: "path": "C:\\\\Users\\\\data"

How to Validate JSON Programmatically

Code patterns for automated syntax validation in APIs, scripts, and pre-commit hooks:

Node.js / JavaScript

function isValidJSON(text) {
  try {
    JSON.parse(text);
    return true;
  } catch (err) {
    console.error("Syntax Error at:", err.message);
    return false;
  }
}

Python 3

import json

def is_valid_json(payload_str):
    try:
        json.loads(payload_str)
        return True
    except json.JSONDecodeError as err:
        print(f"Error at line {err.lineno}, col {err.colno}: {err.msg}")
        return False

Command Line / CI/CD (Bash)

# Validate and exit with non-zero if invalid (great for git pre-commit hooks)
jq empty config.json

# Using Python in terminal
python3 -c "import json, sys; json.load(sys.stdin)" < config.json

Related Developer Tools & Tutorials

Frequently Asked Questions

What are the most common causes of invalid JSON?

The three most frequent errors are: 1) Trailing commas after the last item in an array or object (e.g. {"a": 1,}). 2) Single quotes instead of double quotes for keys or string values. 3) Unescaped special characters (such as raw newlines or unescaped backslashes) inside strings.

Why does JSON strictly prohibit trailing commas?

RFC 8259 intentionally disallows trailing commas to ensure unambiguous, deterministic parsing across hundreds of different programming language implementations. While JavaScript arrays and Python dictionaries permit trailing commas, strict JSON parsers will throw a syntax error.

How do I validate JSON in the command line or CI/CD pipelines?

In Bash or Linux/macOS terminals, use 'jq empty filename.json' (exits with code 0 if valid, non-zero on syntax error) or Python: 'python3 -m json.tool filename.json > /dev/null'. In Node.js CI environments, run 'npx jsonlint filename.json'.

Does this tool validate custom JSON Schemas (draft-07, 2020-12)?

This tool validates structural JSON syntax (RFC 8259). It confirms that the payload is well-formed JSON that any standard parser can deserialize. It does not enforce custom business rules or validate against a domain-specific JSON Schema document.

Do you store or upload my JSON data?

No. The validator runs 100% locally on your machine using the browser's native JavaScript parser. Your data never touches our servers, ensuring total privacy for sensitive tokens, API payloads, and config files.

What is the maximum file size supported?

Because processing is local, performance depends on your device's available memory. Most modern desktop browsers can validate JSON files up to 50MB in less than a second.