JSON Validator

Validate, format, and minify JSON. Paste your JSON below.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. Despite its name, JSON is language-independent and is used across virtually every programming language and platform.

JSON was derived from JavaScript object literal syntax but has become a standard in its own right (ECMA-404 and RFC 8259). It is the dominant format for REST API responses, configuration files (like package.json, tsconfig.json), and data storage in document databases like MongoDB and CouchDB.

JSON supports six data types: strings (double-quoted), numbers (integer or floating-point), booleans (true/false), null, arrays (ordered lists), and objects (key-value pairs). Unlike JavaScript, JSON does not allow functions, dates, undefined, comments, or trailing commas.

How to Use This Tool

  1. 1. Paste your JSON into the text area above
  2. 2. Click Validate to check if the JSON is valid - errors will show the exact position of the issue
  3. 3. Format or Minify to clean up the JSON structure or compress it for transport
  4. 4. Copy the result to your clipboard

Common JSON Errors

Validate JSON in Code

JavaScript

function isValidJSON(str) {
  try {
    JSON.parse(str);
    return true;
  } catch (e) {
    console.error('JSON parse error:', e.message);
    return false;
  }
}

// Pretty print JSON
const formatted = JSON.stringify(obj, null, 2);

// Minify JSON
const minified = JSON.stringify(obj);

Python

import json

def is_valid_json(s):
    try:
        json.loads(s)
        return True
    except json.JSONDecodeError as e:
        print(f"JSON error at line {e.lineno}, col {e.colno}: {e.msg}")
        return False

# Pretty print
formatted = json.dumps(obj, indent=2)

# Minify
minified = json.dumps(obj, separators=(',', ':'))

Go

package main

import (
    "encoding/json"
    "fmt"
)

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

// Pretty print
formatted, _ := json.MarshalIndent(obj, "", "  ")

// Minify
minified, _ := json.Marshal(obj)

Command Line (jq)

# Validate and pretty print
echo '{"name":"test"}' | jq .

# Minify
echo '{"name": "test"}' | jq -c .

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

# Extract a field
curl -s https://api.example.com/data | jq '.results[0].name'

JSON vs Other Formats

Feature JSON XML YAML
Readability Good Verbose Excellent
Comments No Yes Yes
Data types 6 types All strings Rich types
API usage Dominant Legacy/SOAP Rare
Config files Common Some Common

Frequently Asked Questions

What is the difference between JSON.parse() and JSON.stringify()?
JSON.parse() converts a JSON string into a JavaScript object or value. JSON.stringify() does the opposite - it converts a JavaScript object into a JSON string. You use parse() when receiving data (e.g., from an API response) and stringify() when sending data (e.g., in a request body). Both will throw errors on invalid input: parse() throws on malformed JSON, and stringify() throws on circular references.
Can JSON contain comments?
No. The JSON specification (RFC 8259) does not allow comments. Douglas Crockford, the creator of JSON, intentionally excluded them to keep the format simple and interoperable. If you need comments in configuration files, consider using JSONC (JSON with Comments, supported by VS Code), JSON5, or YAML instead. Some tools like jq and certain parsers support a non-standard "JSON with comments" mode, but it is not part of the official spec.
How do I handle dates in JSON?
JSON has no native date type. The most common approach is to use ISO 8601 strings like "2026-02-14T12:00:00Z", which are human-readable and supported by new Date() in JavaScript and datetime.fromisoformat() in Python. Another option is Unix timestamps (seconds since epoch), which are compact but less readable. Choose ISO 8601 for APIs consumed by humans and timestamps for machine-to-machine communication.
What is the maximum size of a JSON document?
The JSON specification imposes no size limit. In practice, limits come from the parser, runtime, or transport layer. JavaScript's JSON.parse() can typically handle strings up to several hundred MB. Most web servers limit request body size (nginx defaults to 1 MB, Express defaults to 100 KB). For very large datasets, consider streaming JSON parsers like JSONStream in Node.js or json.Decoder in Go, which process data incrementally without loading the entire document into memory.

Monitor your JSON APIs

Ensure your APIs return valid JSON responses 24/7. Get alerted when endpoints return malformed data or error status codes.

Start monitoring free →

More Free Tools