JSON Formatter & Validator Online

Paste your JSON to format, validate, and beautify it with proper indentation. Detects syntax errors and supports minification. All processing happens in your browser.

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight, text-based data interchange format defined by RFC 8259. It is human-readable and language-independent, making it the standard format for REST APIs, configuration files, and data storage across nearly all programming ecosystems.

JSON Data Types

TypeExampleNotes
String"hello"Must use double quotes. Escape special chars with \
Number42, 3.14, -1e10No quotes. No NaN or Infinity
Booleantrue, falseLowercase only
NullnullLowercase only
Object{"key": "value"}Unordered key-value pairs. Keys must be strings
Array[1, 2, 3]Ordered list of any values

Common JSON Syntax Errors

JSON Formatting in Code

JavaScript / Node.js

// Pretty print with 2-space indent
const formatted = JSON.stringify(data, null, 2);

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

// Parse and re-format API response
const pretty = JSON.stringify(JSON.parse(responseText), null, 2);

Python

import json

# Pretty print
print(json.dumps(data, indent=2, sort_keys=True))

# Minify
print(json.dumps(data, separators=(',', ':')))

Shell (Linux/macOS)

# Format JSON file with jq
jq . data.json

# Minify
jq -c . data.json

# Extract a nested value
jq '.user.address.city' data.json

JSON Schema Validation

JSON Schema is a vocabulary for annotating and validating JSON documents. It lets you define the expected structure, types, and constraints of your JSON data, enabling automated validation at API boundaries or in CI pipelines.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "age":  { "type": "integer", "minimum": 0 }
  },
  "required": ["name"]
}

Best Practices

Frequently Asked Questions

What is the difference between JSON formatting and validation?

Formatting adds indentation and line breaks for readability. Validation checks structural correctness — balanced braces, properly quoted keys, valid value types, no trailing commas. JSON can be valid but unformatted (minified), or well-formatted but syntactically invalid.

What are common JSON syntax errors?

The most common errors: trailing commas after the last item, single quotes instead of double quotes, unquoted keys, comments (JSON does not support them), and NaN or undefined values. This formatter highlights the exact error location to help you fix them quickly.

When should I minify JSON?

Minify JSON for network transmission (API responses, config downloads) to reduce payload size. Keep JSON pretty-printed in config files, version-controlled files, and anywhere humans need to read or edit it. A 10KB pretty-printed JSON typically compresses to 6–7KB when minified.

Related Format Tools