Free Tool · 10 Validations/Day

JSON Validator
& Formatter

Paste any JSON and instantly validate its syntax, format it for readability, or minify it for production. Clear error messages tell you exactly what's wrong and how to fix it.

Syntax validation Pretty-print & minify Error hints with fixes
// valid json
{
  "name": "Alex",
  "age": 28,
  "active": true
}
Valid JSON
Actions:
10 free validations/day
Input
Output
Formatted JSON will appear here after validation…
Paste JSON to begin
0 chars · 0 lines
the basics

What Is a JSON Validator?

A JSON validator reads your JSON string and checks it against the JSON specification (RFC 8259) to confirm it's syntactically correct. Beyond just saying "valid" or "invalid," a good validator tells you exactly which line has the problem and gives you a hint about what went wrong.

JSON (JavaScript Object Notation) looks simple, but it has strict rules that catch developers off guard — especially if you're coming from JavaScript where unquoted keys and trailing commas are allowed. One missing quote, one extra comma, or one stray comment can break an entire API payload.

This tool validates the syntax, pretty-prints the structure for easy reading, minifies it for production payloads, and calculates stats like total key count and nesting depth — all in one click.

Syntax Validation
Catches every syntax error according to the official JSON spec — wrong quotes, trailing commas, unescaped characters.
Pretty Printing
Reformats minified or messy JSON into a clean, indented structure that's easy to read and debug.
Minification
Strips all whitespace to produce the smallest possible JSON string — ideal for API responses and storage.
Structure Analysis
Shows root type, nesting depth, total key count, and size savings from minification at a glance.
quick reference

JSON Syntax Rules Every Developer Should Know

JSON has only a handful of rules, but breaking any one of them silently kills your API call or config file.

Double quotes only

All strings — both keys and values — must use double quotes. Single quotes are invalid.

✅  {"name": "Alice"}
❌  {'name': 'Alice'}
Keys must be quoted strings

Unlike JavaScript object literals, JSON requires every key to be wrapped in double quotes.

✅  {"age": 30}
❌  {age: 30}
No trailing commas

A comma after the last item in an array or object is invalid in JSON, even though it's fine in JavaScript.

✅  {"a": 1, "b": 2}
❌  {"a": 1, "b": 2,}
No comments

JSON does not support comments of any kind. Neither // single-line nor /* block */ comments are allowed.

✅  {"debug": false}
❌  {"debug": false} // turn off
Lowercase true, false, null

Boolean and null literals must be lowercase. True, False, TRUE, and NULL are all invalid.

✅  {"active": true, "x": null}
❌  {"active": True, "x": NULL}
Properly escaped strings

Special characters inside strings must be escaped. Use \n for newline, \\ for backslash, \" for a literal quote inside a string.

✅  {"path": "C:\\Users\\file"}
❌  {"path": "C:\Users\file"}
error guide

Most Common JSON Errors and How to Fix Them

These are the errors this tool catches most often — and the ones that burn the most debugging time.

1. Unexpected token — unquoted key
You wrote {name: "Alice"} instead of {"name": "Alice"}. Object keys must always be double-quoted strings. This is valid JavaScript but invalid JSON.
2. Unexpected token — single quotes
You used {'key': 'value'}. JSON only accepts double quotes. Replace every single quote around strings with a double quote.
3. Trailing comma
{"a": 1, "b": 2,} — the comma after 2 is invalid. Remove the last comma from any array or object.
4. Unexpected end of JSON input
The JSON was cut off or an opening bracket was never closed. Count your { vs } and [ vs ] — they must balance.
5. Comments inside JSON
{"port": 3000 // default} — comments of any form are invalid in JSON. Remove all // and /* */ lines before validating.
6. Undefined or NaN values
{"count": undefined} or {"ratio": NaN} — these JavaScript primitives do not exist in JSON. Use null instead.
7. Unescaped control characters
Raw newlines or tab characters inside a string literal break the JSON parser. Use \n, \t, and \r escape sequences instead.
8. Duplicate keys
{"id": 1, "id": 2} — duplicate keys are technically parseable but lead to unpredictable results. Different parsers handle them differently. Always use unique keys.
data types

The 6 JSON Data Types Explained

JSON supports exactly six value types. Understanding each one prevents a whole class of validation errors.

String
"Hello, world!"

Any sequence of Unicode characters wrapped in double quotes. Special characters must be escaped with a backslash.

Number
42 | 3.14 | -7 | 1.2e10

Integer or floating-point. No quotes. JSON does not distinguish between int and float. Infinity and NaN are not valid.

Boolean
true | false

Lowercase only. True, TRUE, and False are all syntax errors.

Null
null

Represents an empty or absent value. Lowercase only. Used in place of undefined, None, or nil from other languages.

Object
{"key": "value", "count": 3}

An unordered collection of key-value pairs. Keys must be strings. Values can be any JSON type, including nested objects.

Array
[1, "two", true, null, {"x": 3}]

An ordered list of values. Items can be any JSON type and can mix types freely. Arrays can be nested inside objects and vice versa.

json vs others

JSON vs XML vs YAML — When to Use Each

JSON is the default choice for most APIs, but understanding how it compares helps you pick the right format for your use case.

JSON XML YAML
Human readable ✅ Easy ⚠️ Verbose ✅ Very easy
Comment support ❌ None ✅ Yes ✅ Yes
Data types 6 built-in Strings only Rich types
File size ✅ Compact ❌ Verbose ✅ Compact
Parser availability ✅ Native ⚠️ Library ⚠️ Library
Best for APIs & config Documents & SOAP Config files
FAQ

Frequently Asked Questions About JSON

1 What's the difference between JSON and JavaScript object literals?
JavaScript object literals allow unquoted keys, single quotes, trailing commas, comments, and expressions as values. JSON allows none of these. JSON is a strict data interchange format, not a JavaScript syntax — it just happens to look similar. Code that works in a JavaScript const obj = {} will often fail JSON validation.
2 Why does my JSON look valid but still fail to parse?
The most common invisible culprits are: a BOM (byte order mark) at the start of the file, invisible Unicode characters like zero-width spaces copied from a document editor, or Windows-style line endings causing issues in certain parsers. Paste your JSON here and the validator will catch encoding-related errors.
3 Is the order of keys in a JSON object guaranteed?
No. The JSON specification explicitly states that objects are unordered collections. Most modern JavaScript engines maintain insertion order as an implementation detail, but you cannot rely on this behaviour across all languages and parsers. If order matters, use an array.
4 Can JSON handle large numbers?
JSON itself has no numeric size limit, but JavaScript's JSON.parse() uses IEEE 754 double-precision floats, which lose precision for integers larger than 2^53. If you're working with large IDs or financial values, encode them as strings or use a BigInt-aware parser.
5 What is JSON5 and should I use it?
JSON5 is an unofficial extension of JSON that adds support for comments, trailing commas, single quotes, unquoted keys, and multi-line strings. It's useful for human-edited configuration files. However, most APIs and standard parsers do not accept JSON5 — you need the official JSON format for data exchange.
6 How do I validate nested or complex JSON?
Syntax validation (which this tool does) confirms the structure is well-formed. For validating that specific fields have the right types and required properties exist, you need JSON Schema — a specification for defining the structure of a JSON document. Tools like ajv.js or online schema validators can check JSON against a schema you define.

More free developer tools

Check your website's technical health with our full suite of free SEO and web tools.