JSON Validator

Advanced online JSON syntax validator and schema checker—fully browser-based and privacy-first.

Validate your JSON instantly

Validate JSON with Schema
Supported schema version: Draft-07.

This free online JSON Validator lets you instantly check your JSON data for syntax errors and structural issues. Whether you're validating raw API responses, configuration files, or structured payloads, our tool highlights problems in real time and even offers automatic fixes. For stricter validation, add a JSON Schema and enforce rules like required fields, specific types, and formats (email, URI, etc.). The tool is fully compliant with JSON Schema Draft-07. All processing happens in your browser—your data never leaves your machine.

What is JSON Validation?

JSON (JavaScript Object Notation) is a widely adopted, lightweight data-interchange format, designed to be both human-readable and easy for machines to parse and generate. Its primary purpose is to represent structured data—objects, arrays, strings, numbers, booleans, and nulls—in a language-agnostic way.

JSON validation is the process of programmatically verifying that a JSON document is both syntactically and structurally correct. This involves checking two main aspects:

  • Syntactic Validation: Ensuring that the raw text follows the formal grammar as defined by the ECMA-404 JSON specification. Parsers in most modern programming languages (e.g., JSON.parse() in JavaScript, json.loads() in Python, JSONDecoder in Java) expect valid syntax and will throw errors if the input is malformed.
  • Structural (Schema) Validation: Beyond syntax, schema validation checks that the JSON data matches an expected structure, including data types, required properties, value constraints, and nested objects/arrays. Schema validation is typically done using JSON Schema, which defines rules for what is considered valid data.

Why Validate JSON?

JSON validation is critical wherever data is serialized for transmission, storage, or inter-service communication. Key reasons include:

  • Error Prevention: Detect and report syntax errors (e.g., missing commas, unmatched brackets, illegal characters) early—before attempting to process data.
  • Data Integrity & Security: Reject malformed or malicious JSON payloads, helping prevent backend crashes, injection attacks, or data corruption.
  • Type Safety: Enforce strict typing—ensuring, for example, that a field expected to be a boolean isn't sent as a string, or that UUIDs, emails, or numbers follow the proper format.
  • Cross-Language Compatibility: Guarantee that JSON produced in one environment (e.g., Node.js) will be safely consumable in another (e.g., Python, Go, Java), avoiding serialization/deserialization bugs.
  • Maintainability & Robustness: Validated data structures improve traceability and reduce the risk of hard-to-debug errors in configuration files, logs, or API requests/responses.
  • Privacy & Security: Validation can be performed entirely client-side (in-browser), preventing raw or sensitive data from leaving the user’s device for validation.

Common JSON Validation Errors (with Detailed Examples)

Unquoted Keys

All keys in JSON objects must be double-quoted strings.

{ name: "Alice" }
{ "name": "Alice" }

Many JSON-like formats (e.g., JavaScript object literals) allow unquoted keys, but standard JSON does not.

Single Quotes

JSON strings must use double quotes only; single quotes are not allowed.

{ 'name': 'Bob' }
{ "name": "Bob" }

Using single quotes will result in parser errors in all compliant JSON libraries.

Trailing Commas

No trailing comma after the last item in an object or array.

{
  "a": 1,
  "b": 2,
}
{
  "a": 1,
  "b": 2
}

Trailing commas may work in JavaScript, but not in strict JSON parsers.

Improper Escaping of Characters

Quotes and special characters inside strings must be escaped using a backslash.

{ "quote": "Tom said "hello"" }
{ "quote": "Tom said \"hello\"" }

Other escape sequences include \\ for backslash, \n for newlines, and \t for tabs.

Incorrect Data Types

Strings should not be used for numbers, booleans, or null.

{ "enabled": "true", "count": "10" }
{ "enabled": true, "count": 10 }

JSON distinguishes between booleans, numbers, and strings—ensure the right type is used.

Non-Primitive Keys

JSON object keys must always be strings; you cannot use numbers, booleans, or other types as keys.

{ 123: "abc" }
{ "123": "abc" }

Duplicate Keys

While allowed by the JSON spec, duplicate keys are a common source of bugs.

{ "name": "Alice", "name": "Bob" }

Most parsers will only keep the last value ("Bob"), silently discarding earlier ones.

Use of Comments

Standard JSON does not allow comments, even though some editors support them.

{
  // User information
  "name": "Alice"
}
{
  "name": "Alice"
}

Schema Validation: Enforcing Structure and Data Types

JSON Schema is a powerful standard for defining and validating the expected structure of JSON documents. It allows you to specify:

  • Required fields (`required`)
  • Data types (`type`: string, number, boolean, object, array, null)
  • String formats (`format`: email, uuid, date-time, etc.)
  • Pattern matching for strings (`pattern`)
  • Number ranges (`minimum`, `maximum`)
  • Array length and item validation (`minItems`, `maxItems`, `items`)
  • Nested validation for objects and arrays
  • Enum constraints (`enum`)

Example: User Schema (Draft-07)

{
  "type": "object",
  "properties": {
    "id":    { "type": "string", "format": "uuid" },
    "name":  { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "is_active": { "type": "boolean" }
  },
  "required": ["id", "name", "email"],
  "additionalProperties": false
}

What this enforces:

  • id must be a valid UUID string.
  • name must be a non-empty string.
  • email must match standard email format.
  • is_active (optional) must be a boolean.
  • No properties other than those defined above are allowed.

Real-World Example: Validating Stripe API Responses

Suppose you receive JSON responses from the Stripe API (e.g., PaymentIntent). Schema validation can ensure you never process incomplete or incorrectly typed data.

{
  "type": "object",
  "properties": {
    "id":      { "type": "string", "pattern": "^pi_" },
    "object":  { "type": "string", "const": "payment_intent" },
    "amount":  { "type": "integer", "minimum": 1 },
    "currency":{ "type": "string", "minLength": 3, "maxLength": 3 },
    "status":  { "type": "string", "enum": [
      "requires_payment_method",
      "requires_confirmation",
      "processing",
      "succeeded",
      "canceled"
    ]}
  },
  "required": ["id", "object", "amount", "currency", "status"],
  "additionalProperties": false
}
  • id must start with "pi_"
  • object must always be "payment_intent"
  • amount must be an integer greater than or equal to 1
  • currency must be a three-letter string (e.g., "usd", "eur")
  • status must be one of the specified values

Benefits

  • Early Error Detection: Catch breaking API changes or incomplete data before it reaches your business logic.
  • Automated Testing: Use schemas in CI/CD pipelines to validate real and mock responses.
  • Cross-team Consistency: Standardize data contracts between frontend, backend, and third-party APIs.

Proper JSON validation—covering both syntax and schema—prevents subtle bugs, enforces best practices, and secures your applications against malformed or malicious input. Whether used in configuration files, API payloads, or inter-service messaging, robust validation is foundational for modern software systems.

Privacy & Security

All validation and schema checks run locally in your browser. No data is uploaded or logged. Your JSON stays fully private.

Code Examples for JSON Validation

See how to validate JSON in various programming languages using built-in libraries or popular frameworks. These examples demonstrate both syntax validation and schema validation.

JavaScript (Node.js)
Install: Standard library
const jsonString = '{"name":"Alice","age":30}';
try {
  const obj = JSON.parse(jsonString);
  console.log("Valid JSON:", obj);
} catch (e) {
  console.error("Invalid JSON!", e.message);
}
JavaScript (Node.js) with ajv (Schema validation)
Install: npm install ajv
const Ajv = require("ajv");
const ajv = new Ajv();
const schema = { type: "object", properties: { age: { type: "integer" } }, required: ["age"] };
const data = { age: 30 };
const validate = ajv.compile(schema);
console.log(validate(data) ? "Valid!" : ajv.errorsText(validate.errors));
Python
Install: Standard library (json)
import json
try:
    obj = json.loads('{"name":"Alice","age":30}')
    print("Valid JSON:", obj)
except json.JSONDecodeError as e:
    print("Invalid JSON:", e)
Python with jsonschema
Install: pip install jsonschema
import json, jsonschema
schema = {
    "type": "object",
    "properties": { "age": { "type": "integer" } },
    "required": ["age"]
}
data = {"age": 30}
try:
    jsonschema.validate(data, schema)
    print("Valid!")
except jsonschema.ValidationError as e:
    print("Schema validation error:", e)
Go
Install: Standard library (encoding/json)
package main
import (
  "encoding/json"
  "fmt"
)
func main() {
  data := []byte(`{"name":"Alice","age":30}`)
  var obj map[string]interface{}
  if err := json.Unmarshal(data, &obj); err != nil {
    fmt.Println("Invalid JSON:", err)
  } else {
    fmt.Println("Valid JSON:", obj)
  }
}
Java
Install: com.fasterxml.jackson.core:jackson-databind
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
  public static void main(String[] args) {
    String json = "{"name":"Alice","age":30}";
    try {
      Object obj = new ObjectMapper().readTree(json);
      System.out.println("Valid JSON: " + obj);
    } catch (Exception e) {
      System.out.println("Invalid JSON: " + e.getMessage());
    }
  }
}
C#
Install: Standard library (System.Text.Json)
using System;
using System.Text.Json;
class Program {
  static void Main() {
    string json = "{"name":"Alice","age":30}";
    try {
      var doc = JsonDocument.Parse(json);
      Console.WriteLine("Valid JSON!");
    } catch (JsonException e) {
      Console.WriteLine("Invalid JSON: " + e.Message);
    }
  }
}
PHP
Install: Standard library (json_decode)
<?php
$json = '{"name":"Alice","age":30}';
$obj = json_decode($json);
if (json_last_error() === JSON_ERROR_NONE) {
  echo "Valid JSON";
} else {
  echo "Invalid JSON: " . json_last_error_msg();
}
Ruby
Install: Standard library (json)
require 'json'
begin
  obj = JSON.parse('{"name":"Alice","age":30}')
  puts "Valid JSON!"
rescue JSON::ParserError => e
  puts "Invalid JSON: #{e.message}"
end
Bash (Linux/macOS) with jq
Install: brew install jq (or apt-get install jq)
echo '{"name":"Alice","age":30}' | jq empty && echo "Valid" || echo "Invalid"
Rust
Install: cargo add serde_json
fn main() {
  let data = r#"{"name":"Alice","age":30}"#;
  match serde_json::from_str::<serde_json::Value>(data) {
    Ok(_) => println!("Valid JSON!"),
    Err(e) => println!("Invalid JSON: {}", e),
  }
}
Kotlin
Install: Standard library (org.json)
import org.json.JSONObject
fun main() {
  try {
    val obj = JSONObject("{\"name\":\"Alice\",\"age\":30}")
    println("Valid JSON: $obj")
  } catch (e: Exception) {
    println("Invalid JSON: ${e.message}")
  }
}
Swift
Install: Standard library (JSONSerialization)
import Foundation
let json = "{\"name\":\"Alice\",\"age\":30}"
if let data = json.data(using: .utf8) {
  do {
    let _ = try JSONSerialization.jsonObject(with: data)
    print("Valid JSON!")
  } catch {
    print("Invalid JSON: \(error)")
  }
}
TypeScript
Install: Standard library
const jsonString = '{"name":"Alice","age":30}';
try {
  const obj = JSON.parse(jsonString);
  console.log("Valid JSON:", obj);
} catch (e) {
  console.error("Invalid JSON!", e.message);
}
SQL (PostgreSQL)
Install: Standard (with jsonb functions)
SELECT '{"name":"Alice","age":30}'::jsonb; -- Will error if not valid JSON
MySQL
Install: Standard (5.7+)
SELECT JSON_VALID('{"name":"Alice","age":30}');
PowerShell
Install: Standard
$json = '{"name":"Alice","age":30}'
try {
  $obj = $json | ConvertFrom-Json
  Write-Output "Valid JSON!"
} catch {
  Write-Output "Invalid JSON: $($_.Exception.Message)"
}
Perl
Install: cpan JSON
use JSON;
my $str = '{"name":"Alice","age":30}';
eval { decode_json($str) };
print $@ ? "Invalid JSON: $@" : "Valid JSON!";
Dart
Install: Standard library (dart:convert)
import 'dart:convert';
void main() {
  const jsonString = '{"name":"Alice","age":30}';
  try {
    final obj = jsonDecode(jsonString);
    print('Valid JSON: $obj');
  } catch (e) {
    print('Invalid JSON: $e');
  }
}
Elixir
Install: mix deps.get jason
json = ~s({"name":"Alice","age":30})
case Jason.decode(json) do
  {:ok, _} -> IO.puts("Valid JSON!")
  {:error, err} -> IO.puts("Invalid JSON: #{err}")
end
Scala
Install: libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.4"
import play.api.libs.json._
object Main extends App {
  val str = """{"name":"Alice","age":30}"""
  try {
    val json = Json.parse(str)
    println("Valid JSON!")
  } catch {
    case e: Exception => println("Invalid JSON: " + e.getMessage)
  }
}

About this tool

This tool is developed by the team at Itself Tools, creators of a wide range of fast, privacy-first online utilities used by millions worldwide. With years of experience building browser-based tools that prioritize simplicity, speed, and reliability, we’ve expanded into developer-focused applications like this one—designed to make technical tasks easier for programmers, analysts, and digital professionals.