🧰 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.
- 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:
- 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
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
- Numbers are rewritten. 1.0 comes back as 1, 1e3 as 1000, and an integer longer than about 16 digits loses its tail: 12345678901234567890 returns as 12345678901234567000.
- Duplicate keys collapse. Two entries with the same name are valid input, but only the last survives, with no warning.
- Keys that look like whole numbers move to the front in ascending order, so "2" before "1" comes back reversed. Other keys keep their original order.
- Escapes are resolved. A Unicode escape comes back as the character itself - equivalent JSON, but no longer plain ASCII.
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.