JSON Formatter & Validator
Beautify, minify, or validate JSON. Explore nested data with an interactive tree view.
Related Tools
How to Use
- Paste Your JSON — Type or paste JSON data into the editor. The tool accepts any valid JSON — objects, arrays, nested structures, strings, numbers, booleans, and null values.
- Choose an Action — Click Beautify to format with 2-space indentation, Minify to compress to one line, or Validate to check if the JSON is valid. If there is a syntax error, the tool shows the browser's error message, plus the line, column, and surrounding text whenever that message includes a position (Firefox's messages do; current Chrome and Edge include one for most errors).
- Explore & Export — Switch to Tree View to explore nested data with collapsible nodes. Copy the formatted/minified output or download as a .json file. Stats show line count and size comparison.
About the JSON Formatter & Validator
The JSON Formatter & Validator checks whether text is valid JSON, re-indents it so you can read it, or compresses it onto one line, and it adds a collapsible Tree View for exploring nested data. Developers use it for API responses, configuration files and log lines. Testers and analysts use it to inspect exports without opening an IDE.
How formatting works
Your text is first validated with the browser's built-in JSON.parse, which accepts only strict JSON: double-quoted keys and strings, no comments, no trailing commas, no NaN, undefined or leading zeros. If it passes, the tool re-indents your original text instead of rebuilding it from the parsed values. That choice has practical effects:
- Numbers keep their exact digits.
1.50stays1.50,1e3stays1e3, and 64-bit IDs larger than 9,007,199,254,740,991 (2^53 − 1) are not rounded. - String escapes stay as written (
\u00e9is not turned intoé), and key order and duplicate keys are kept. - Beautify indents with two spaces, puts a space after each colon and keeps empty
{}and[]on one line. Minify removes every whitespace character outside strings.
The Tree View is different: it shows values the way JavaScript reads them. Objects show their property count and arrays their item count, and each node collapses with a click or the keyboard. Because it uses parsed values, very large integers appear rounded there, 1.50 appears as 1.5, and with duplicate keys only the last value is shown.
Worked example
Input, all on one line:
{"id":9007199254740993,"price":1.50,"tags":[],"name":"Caf\u00e9"}
Beautify output:
{
"id": 9007199254740993,
"price": 1.50,
"tags": [],
"name": "Caf\u00e9"
}
The tool also warns that 1 integer is larger than JavaScript can store exactly (for example 9007199254740993). In the Tree View the same ID appears as 9007199254740992, the price as 1.5 and the name as Café, while the formatted text keeps the original digits and escape.
Now an invalid file with a trailing comma:
{
"a": 1,
"b": 2,
}
The tool reports Invalid JSON — error at line 4, column 1, adds the browser's message, and shows the surrounding text with a ⟨HERE⟩ marker just before the closing brace. Remove the comma after 2 and it validates.
Limitations
- Strict JSON only. JSON5 and "JSON with comments" files, single-quoted strings and unquoted keys are rejected. Remove those features first.
- Only the first error is reported, because
JSON.parsestops there. Fix it and validate again. - The line and column come from your browser's error message. Firefox's messages include them. Current Chrome and Edge include a position for most errors, but not for an unexpected value such as
NaN,undefinedor[1,]. Safari's messages have no position. In those cases you see the message only. - Indentation is fixed at two spaces, and there is no key sorting, schema validation or conversion to other formats.
- The Tree View creates a page element for every value, so very large files are slow to display there. The Formatted tab stays fast.
Practical tips
- If clean-looking JSON fails right at the start, the text may begin with an invisible byte order mark or contain zero-width spaces. Check it with the Invisible Character Detector.
- Text with single quotes and unquoted keys is usually a JavaScript object, not JSON. Paste it into the JS tab of the Code Playground and log
JSON.stringify(obj, null, 2)to convert it. - Minify before putting JSON into a single-line setting such as an environment variable or a
data-attribute. Escapes are kept, so the value stays identical. - For JSON-LD structured data, the Schema Markup Generator builds the JSON for you.
Validation and formatting use your browser's own JSON engine, so API keys, tokens and customer records in your JSON are never uploaded.
Frequently Asked Questions
What does Beautify do?
Beautify validates your JSON with the browser's native JSON.parse and then re-indents your original text with 2-space indentation and consistent line breaks. Because it re-indents the text instead of re-serializing parsed values, numbers keep their exact digits (even very large integers), and string escapes and key order stay exactly as you wrote them. This makes deeply nested JSON readable and easy to understand.
What does Minify do?
Minify removes all unnecessary whitespace and line breaks from your JSON, producing the most compact representation. This is useful for reducing file size when transmitting JSON over a network or storing it in a database. The output is valid JSON — just compressed to a single line.
How does error detection work?
When you click Validate (or Beautify/Minify on invalid JSON), the tool uses the browser's native JSON.parse, which throws an error describing the problem. Firefox reports the line and column, and current Chrome and Edge report the character position for most errors; the tool turns either into a line, column, and a snippet of the surrounding text so you can find and fix the issue quickly. Chrome and Edge give no position when an unexpected value appears (for example NaN, undefined, or a trailing comma inside an array), and Safari's error messages never include one, so in those cases the tool shows the message only.
What is the Tree View?
Tree View displays your JSON as an interactive, collapsible hierarchy. Objects show their property count, arrays show their item count. Click the arrow icons to collapse or expand sections. This is useful for exploring large JSON responses from APIs or configuration files without scrolling through raw text.
Can it handle large JSON files?
Yes, within the limits of your device's memory. Validation uses the browser's built-in JSON.parse, and Beautify and Minify are a single pass over your text, so files of several megabytes are practical on a typical computer. The Tree View creates a page element for every value, so very large files take noticeably longer to display there; the Formatted tab stays fast.
Is my JSON data sent to a server?
No. All parsing, formatting, minification, and validation happens in your browser using JavaScript's built-in JSON methods. Your data never leaves your device. This is safe for API keys, configuration data, user records, and any sensitive JSON.
What happens to very large numbers?
JavaScript can only store integers exactly up to 9,007,199,254,740,991 (2^53 - 1). Beautify and Minify work on your original text, so larger integers such as 64-bit IDs keep every digit in the formatted output. The Tree View, however, displays values as JavaScript reads them, so such integers can appear rounded there; the tool warns you when your JSON contains them.