JSON Formatter & Validator
Beautify and validate JSON data — with syntax highlighting and error detection
How to Use the JSON Formatter & Validator
- Paste raw or minified JSON into the input field.
- Click Format to beautify with syntax highlighting.
- Use the tree view to collapse and expand individual nodes.
- Click any key to copy its JSON path.
- Use Search to find keys in large JSON objects.
What does this tool do?
The JSON Formatter validates your JSON for syntax errors and displays it in a readable, indented format with colour-coded keys, strings, numbers, and booleans. The collapsible tree view lets you navigate large JSON structures without scrolling through thousands of lines.
What is a JSON Formatter?
A JSON formatter (also called JSON beautifier or JSON prettifier) takes minified or unformatted JSON and adds proper indentation and line breaks to make it human-readable. JSON (JavaScript Object Notation) is a lightweight data format widely used in APIs, config files, and data storage.
Common Uses
- Formatting API responses for debugging and readability
- Validating JSON structure before using it in code
- Prettifying JSON config files (package.json, tsconfig.json, etc.)
- Inspecting nested JSON objects and arrays from logs
Frequently Asked Questions
How do I validate JSON online?
Paste your JSON into the formatter. If it contains errors, the validator will highlight the exact line and character where the syntax breaks. Common errors include trailing commas, unquoted keys, and single quotes instead of double quotes.
What is the difference between JSON and JavaScript objects?
JSON is a strict text format — all keys must be double-quoted strings, trailing commas are not allowed, and functions are not supported. JavaScript objects are more flexible and are runtime constructs, not text.
What does "unexpected token" mean in JSON?
It means the parser found a character it didn't expect. Common causes: a trailing comma after the last item in an array or object, single quotes instead of double quotes, or an unquoted key name.
Notes from this implementation
Parse, then print
The formatter runs a real JSON parse, then prints the value with indentation. It is not a regex that inserts newlines after commas. Trailing commas, single quotes, and comments fail the parse, which is what you want: those files are not JSON, even if a particular program accepts them as JSON5 or as a JavaScript object.
An error worth reading
{"a":1,}
That trailing comma is the usual “unexpected token.” The parser stops at the comma. It does not tell you the author’s intent. Remove the comma or quote the keys and try again. Duplicate keys are allowed by the grammar and the second value wins in JavaScript’s JSON.parse. If you are comparing two payloads, look for duplicate keys before you trust a pretty print.
The tree view is for reading. It does not preserve key order beyond what the parse preserved, and it will not keep a number that is larger than the safe integer range as an exact integer. A long Twitter-style id can change if it is parsed as a number. Quote those ids in the source if the exact digits matter.