JSON Formatter

Format, validate, and minify JSON with syntax error detection, entirely in your browser.

Valid JSON
Input
Formatted output

About the JSON Formatter

JSON (JavaScript Object Notation) is a text data format built from six value types: objects ({...}), arrays ([...]), strings, numbers, booleans, and null. It looks like JavaScript but is stricter — keys and string values must use double quotes, trailing commas aren't allowed, and comments have no place in the spec at all. This tool validates against those exact rules using the browser's native JSON.parse, so an error here means the JSON would also fail to parse in any standard JSON consumer, not just a stylistic complaint.

To use it: paste or type JSON into the input box — it validates on every keystroke, showing "Valid JSON" or the exact parse error. Click Format to re-indent it with 2 or 4 spaces per level for readability, or Minify to strip every non-essential space and line break for the smallest possible payload. For example, the compact input {"name":"WikiSolutions","tools":16} formats with 2-space indent to a three-line, easy-to-scan block, while minifying a formatted document returns it to that same compact single line. The formatted output can be copied or downloaded as a .json file directly from the output panel.

Does my JSON leave my browser?+

No — formatting, validation, and minifying all run locally with JSON.parse/JSON.stringify. Nothing is sent anywhere.

Why does it reject JSON with a trailing comma?+

Trailing commas after the last item in an object or array are valid in JavaScript object literals but not in the stricter JSON spec, so JSON.parse rejects them — remove the comma before the closing } or ].

Why does it reject single-quoted strings or unquoted keys?+

JSON requires double quotes around both string values and object keys. Single quotes and unquoted keys are valid JavaScript but not valid JSON, and will show as a syntax error here.

What does the error message location mean?+

The validator reports the character position where parsing failed, based on the browser's native JSON.parse error — count from the start of your input to find exactly where the malformed syntax begins.

What is the difference between Format and Minify?+

Format pretty-prints with your chosen indentation (2 or 4 spaces) and line breaks for readability. Minify strips all non-essential whitespace to produce the smallest possible valid JSON, typically used before sending data over a network.

Does formatting change the data itself?+

No — formatting and minifying only change whitespace and indentation. Key order and all values are preserved exactly (object key order is preserved by JSON.stringify following insertion order for string keys).