JSON Formatter & Schema Validator
What It Is
This tool formats, minifies, and validates JSON documents, with a separate schema validation mode that checks JSON payloads against JSON Schema Draft 07 and 2020-12 definitions. Developers use it for debugging API responses, validating configuration files, ensuring data integrity before processing, and catching structural errors that would otherwise surface at runtime.
How It Works
The formatter uses JSON.parse() to validate syntax, then JSON.stringify(parsed, null, indent) to produce prettified output. Minification uses the same approach with no whitespace.
Worked Example
Input (unformatted): {"name":"John","age":30,"city":"New York"}. Format output (2-space indent):
{
"name": "John",
"age": 30,
"city": "New York"
}Schema validation example: The validator checks the JSON payload against the schema definition, returning any validation errors found.
Common Mistakes
- Trailing commas. JSON does not allow a comma after the last property.
- Unquoted or single-quoted keys. JSON requires double-quoted property names.
- Mixing JSON Schema drafts. Draft 2020-12 moved tuple validation from
itemstoprefixItems.
Frequently Asked Questions
Q:What is JSON and why format it?
JSON (JavaScript Object Notation) is a lightweight data interchange format. Formatting makes JSON human-readable by adding proper indentation, which is essential for debugging, code reviews, and understanding nested structures.
Q:What is JSON Schema validation?
JSON Schema defines the structure and constraints of JSON data. It validates that JSON conforms to expected types, required properties, and value ranges. This tool validates against Draft 07/2020-12 schemas to ensure data integrity before processing.
Q:Why am I seeing a JSON syntax error?
Common JSON errors include trailing commas after the last property, using single quotes instead of double quotes, forgetting to quote property names, or having mismatched brackets. The formatter highlights the exact line and column where the error occurs.
Q:What is the difference between JSON Schema Draft 07 and 2020-12?
Draft 2020-12 introduced several changes: <code>$defs</code> replaces <code>definitions</code>, <code>prefixItems</code> replaces <code>items</code> tuple validation, <code>unevaluatedProperties</code> was added, and the meta-schema URI changed to <code>https://json-schema.org/draft/2020-12/schema</code>. This tool supports both drafts.
Q:Does the schema validator support <code>$ref</code> and external references?
The built-in validator handles inline validation rules — type checks, required properties, pattern matching, enumerations, and numeric bounds. For <code>$ref</code> resolution across multiple schema files, you would need a full schema registry, which is available in the Pro tier.
Q:How do I use the Tree View?
Switch to the Tree View tab and paste your JSON. The tree renders every node as a collapsible row. Click on <code>▶</code> to expand nested objects and arrays. Hover over any node and click <code>[> Copy Path]</code> to copy its JSON path (e.g. <code>$.users[0].name</code>).
Q:How does the Compare mode work?
Paste two JSON documents into the left and right textareas, then click <code>[> Compare]</code>. The tool parses both documents and highlights every difference using a line-level diff. Added lines appear in green, removed lines in red, and unchanged lines in the default colour.