What is JSON and why does it need formatting?
JSON (JavaScript Object Notation) is the most widely used data interchange format on the internet. APIs return JSON, configuration files are written in JSON, and databases export to JSON. The problem is that JSON sent over the wire or stored in files is often minified — compressed into a single line with all whitespace removed — which makes it nearly unreadable.
A JSON formatter takes that compressed, difficult-to-read JSON and adds proper indentation, line breaks, and structure so you can see exactly what you are working with at a glance.
Using the ToolHive JSON formatter
Paste your JSON into the left panel and click "Format" or press Ctrl+Enter. The formatted result appears immediately in the right panel with colour-coded syntax highlighting: keys appear in indigo, string values in orange, numbers in green, and booleans and null in blue and grey respectively.
The tool also runs automatically as you type in the input panel, showing a live validity indicator so you know the moment your JSON becomes invalid — and exactly why, with the precise error message from the parser.
Choosing an indent style
The indent selector at the top lets you choose between 2 spaces (default, compact and readable), 4 spaces (more traditional, common in Python projects), or tab indentation (common in older codebases and some editors). The choice is mostly stylistic but some code review tools and linters have preferences.
Validating JSON
JSON validation is automatic. The status bar below the editor shows a green "Valid JSON" message when your JSON is well-formed, or a red error message with the exact parser error when it is not. Common JSON errors include trailing commas (which are not allowed in JSON, unlike JavaScript), unquoted keys, single-quoted strings, and missing closing braces or brackets.
Minifying JSON for production
The Minify button does the opposite of formatting: it removes all whitespace and produces the most compact valid JSON possible. This is useful before embedding JSON in production code, API payloads where bandwidth matters, or when you need to fit JSON into a single environment variable.
The size comparison shown after minification makes it easy to see exactly how much space you save — often 20–40% for typical API responses.
Understanding the stats panel
The stats bar below the editor shows four values: total key count (the sum of all keys at all nesting levels), maximum depth (how many levels deep the deepest nested object or array goes), file size (in bytes or kilobytes), and root type (Object or Array). These are useful for understanding the structure of an unfamiliar JSON payload at a glance.
Common use cases
Debugging API responses is the most common use case — paste a response from Postman, curl, or your browser's network tab and immediately see the structure clearly. Configuration file editing is another common case, especially for complex tools like Webpack, ESLint, and package.json files. Log analysis, where application logs emit JSON events, becomes much easier when you can format individual log lines.