What Is a JSON Formatter & Validator?
This tool parses your JSON using the browser's own genuine JSON.parse() function - the same
parser real applications use - then either pretty-prints it with clean indentation or reports the exact
syntax error if it's invalid. Because it uses a real parser rather than a simplified syntax checker, the
validation result reflects exactly what a real JSON consumer, like an API or programming language, would
accept or reject.
How to Use the JSON Formatter & Validator
- Paste strict JSON into JSON Input and choose Format & Validate for readable indentation, Minify for compact JSON, or Validate Only to check syntax without rewriting it.
- Choose 2 spaces, 4 spaces or tabs for formatting. If the JSON is invalid, read the native browser parser error and its line/column when the browser reports one; select the highlighted location if available.
- Review the conversion-safety message. Duplicate object keys, unsafe integers, negative zero, non-finite values and high-precision decimal tokens block rewriting to prevent silent changes.
- Open JSON Tree to expand objects and arrays. For structure checks, select Schema Check, paste a schema using the supported subset, and click Validate Against Schema. Unsupported keywords produce NOT EVALUATED instead of a false pass.
- Open JSON Diff, paste a second JSON document and click Compare JSON. Read added, removed and changed values by JSON Pointer path; arrays are compared by index.
- After safe formatting or minification, use Copy Output or Download .JSON. No data is sent to a remote processor by this widget.
How It Works
The browser first runs native JSON.parse() to confirm strict JSON syntax. A second local token scan examines the original input text for repeated object keys and numeric tokens that can be changed by JavaScript number conversion. When rewriting is safe, JSON.stringify() creates the indented or compact output. The expandable tree presents the parsed data locally, and JSON Diff compares parsed values with object-key order ignored.
Schema Check implements a clearly limited subset of JSON Schema keywords: type, properties, required, additionalProperties, items, numeric bounds, string length limits, array/object length limits, uniqueItems, enum and const. It does not claim full JSON Schema draft validation; unsupported features such as $ref, anyOf, format or pattern are explicitly rejected. For complete standards validation, use a dedicated JSON Schema validator.
Understanding Your Results
- VALID JSON means the browser accepted strict JSON syntax; this does not prove application-specific correctness.
- INVALID JSON means native
JSON.parse()rejected the input. The exact wording and whether a line and column are supplied depend on the browser. - VALID, UNSAFE TO REWRITE means syntax is valid but ordinary parse/stringify could alter the original information, such as duplicate keys or precision-sensitive numbers. Output is withheld instead of silently changing it.
- SCHEMA SUBSET PASS/FAIL reports only the listed supported schema rules. NOT EVALUATED means a schema rule or document exceeds the defined validation limits.
- JSON Diff shows changed paths using JSON Pointer syntax. Key order is ignored, while array order is significant. The list displays up to 150 changes.
Browser Limitations
Strict JSON does not allow trailing commas, comments, unquoted keys or single-quoted strings. Very large documents can consume substantial browser memory. This tool limits each input to 1,048,576 UTF-16 code units and applies depth, node, tree-view and difference-list limits; oversized work returns an explicit warning, not a silent success. Browsers may word syntax errors differently, and a character position is shown only if the parser reports a usable one. Browser clipboard/download permissions may vary. This tool does not evaluate external JSON Schema references or every feature in any particular JSON Schema draft.
Common Mistakes to Avoid
- Using single quotes instead of double quotes - valid JSON requires double quotes for strings and keys; single quotes will produce a syntax error.
- Leaving a trailing comma after the last item - this is allowed in JavaScript object literals but is invalid in strict JSON and will be flagged as an error here.
- Forgetting to quote object keys - JSON requires all keys to be quoted strings, unlike plain JavaScript objects which allow unquoted keys.
Frequently Asked Questions
Why does my JSON fail here but work fine as a JavaScript object?
JavaScript object literal syntax is more permissive than strict JSON - allowing unquoted keys, single quotes, and trailing commas - while this tool validates against the stricter, standard JSON specification that most APIs and parsers actually require.
What does "unexpected token" mean in the error message?
It means the browser parser encountered unexpected JSON syntax. When the browser reports a character position or line/column, the tool displays it; if no position is available, it shows the original parser message without inventing one.
Does this tool validate against a specific schema?
Yes, with a disclosed local subset of common JSON Schema keywords (including type, properties, required and array limits). It is not a complete JSON Schema draft validator; unsupported keywords return NOT EVALUATED rather than PASS.
Is my pasted JSON sent to a server?
No, all parsing, formatting, and validation happens entirely within your browser using built-in JavaScript functions - nothing you paste is transmitted anywhere.
Can I format very large JSON files with this tool?
Input is capped at 1,048,576 UTF-16 code units per document, with further node and depth limits. Larger or deeply nested documents are explicitly refused instead of risking a frozen browser or silently truncated output.
Conclusion
Whether you're debugging an API response or cleaning up a messy config file, this provides genuine syntax validation, conservative formatting, tree inspection, supported schema checks and a structured diff without silently rewriting unsafe numeric tokens or duplicate keys. For working with encoded data more generally, check the Base64 Encoder/Decoder.