🧰 JSON Formatter & Validator

Format, validate, and beautify JSON data with syntax highlighting and error detection. Perfect for developers debugging APIs, working with configuration files, and analyzing JSON responses.

📊 Formatted Output:
Formatted JSON will appear here...
💡 How it works:
  • Paste raw JSON or minified JSON in the textarea
  • Click "Format JSON" to beautify and validate
  • The tool automatically detects JSON errors with line numbers
  • Use "Minify" to compress JSON into a single line
  • Click "Copy Result" to copy formatted JSON to clipboard
  • Statistics show object and array counts

📝 Examples:

Input (Minified/Raw):
{"name":"John","age":30,"city":"New York","hobbies":["reading","gaming"]}
Output (Formatted):
{ "name": "John", "age": 30, "city": "New York", "hobbies": [ "reading", "gaming" ] }
Invalid JSON Error:
{"name":"John",age:30} // Missing quotes around 'age' ❌ Syntax Error: Unexpected token in JSON
📚 Use Cases:
  • Debug API responses and JSON data structures
  • Validate configuration files (package.json, config.json, etc.)
  • Format JSON for better readability and sharing
  • Minify JSON for production and performance optimization
  • Analyze JSON structure and hierarchy
  • Identify syntax errors in JSON files
  • Convert between formatted and minified JSON
ℹ️ Note: This tool parses JSON locally in your browser. No data is sent to any server.

What Format and Minify actually do

Both buttons run the same two steps: the browser's own JSON parser reads your text, and the resulting value is written back out. Validation is therefore exactly the JSON standard, with no house rules of its own:

Format : JSON.stringify(JSON.parse(input), null, 2)
Minify : JSON.stringify(JSON.parse(input))

Format indents with two spaces; Minify strips every space and line break. If the parse fails, the output box empties and the parser's own message appears, naming the position, line and column where it gave up - usually one character past the real mistake.

What a round trip changes

The three figures under the output are counted crudely: the Objects and Arrays numbers are how many opening braces and brackets appear in the minified text, so a brace inside a string value is counted as an object. Chars is the minified length, not the length of the indented text you are looking at.

Frequently asked questions

Why does it say my JSON is invalid when it looks right?

The four usual causes are a trailing comma after the last item, single quotes instead of double, an unquoted key, and a comment. All are fine in JavaScript and none are allowed in JSON. Check the position in the error, then the line above it.

Does formatting change my data?

The text changes, and the values almost never do. The exceptions are worth knowing: numbers are re-written in their shortest form, very large integers are rounded to what a double can hold, and duplicate keys are silently reduced to the last one.

Is my JSON uploaded anywhere?

No. Parsing and formatting happen in your browser, and nothing is sent to a server, so a config file or an API response with credentials in it does not leave the machine.