JSON Formatter & Validator - Beautify or Minify JSON
Format, validate, minify and repair JSON in your browser. Explore it as a tree, fix common syntax errors, and convert JSON to YAML or XML. No sign-up.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.
JSON is a text format that is completely language independent but uses conventions that are familiar to programmers.
What do formatting and minifying JSON do?
Formatting, also called pretty-printing or beautifying, parses JSON and writes it back with line breaks and consistent indentation so nesting is easy to follow. Minifying does the reverse and removes every space and line break that is not inside a string, which makes payloads smaller for APIs, configuration and storage. For ordinary JSON neither changes the data: keys, values and their order stay the same.
This tool parses your input with the browser's built-in JSON parser and writes it back with an indent of 2, 4 or 8 spaces, or with no whitespace when you minify. Invalid input is reported with the parser's error message, which varies between browsers but usually points to the position where parsing stopped.
{"id":42,"name":"Ada","tags":["math","code"],"active":true}{
"id": 42,
"name": "Ada",
"tags": [
"math",
"code"
],
"active": true
}What are common JSON errors and how do I fix them?
JSON, defined in RFC 8259 and ECMA-404, is stricter than JavaScript object syntax. These are the mistakes that most often make a parser reject a file.
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'x'} | {"a": "x"} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comment | {"a": 1 /* note */} | {"a": 1} |
| NaN, Infinity or undefined | {"a": NaN} | {"a": null} |
| Python or other literals | {"ok": True, "v": None} | {"ok": true, "v": null} |
| Leading zero | {"zip": 02134} | {"zip": "02134"} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Raw line break in a string | "line one⏎line two" | "line one\nline two" |
The Fix button runs the open-source jsonrepair library, which can repair many of these automatically, including comments, trailing commas, single quotes, unquoted keys, missing commas and Python-style True, False and None. Repair is a best guess, so check the result before you use it.
Two valid inputs can still surprise you. JavaScript numbers lose precision above 9,007,199,254,740,991 (2^53 − 1), so a long numeric ID may change when formatted; store such IDs as strings. Duplicate keys are allowed by the grammar, but the parser keeps only the last value, so the formatted output drops the earlier ones.
What is the difference between JSON, JSON5 and YAML?
| Feature | JSON | JSON5 | YAML |
|---|---|---|---|
| Comments | No | Yes | Yes |
| Trailing commas | No | Yes | Not needed |
| Indentation defines structure | No | No | Yes |
| Unquoted keys | No | Yes | Yes |
| Single-quoted strings | No | Yes | Yes |
| Typical use | APIs, data exchange | Hand-edited config | Config files, CI pipelines |
JSON5 extends JSON with JavaScript-style conveniences and needs a JSON5 parser to read. YAML 1.2 treats almost any JSON document as valid YAML, and relies on indentation instead of braces. The formatter can convert valid JSON to YAML or XML, and can generate TypeScript, Python, Java, Go, C#, Rust or Swift types and a JSON Schema from a sample.
Is my JSON sent to a server?
Parsing, formatting, minifying, repair, conversion and code generation all run in JavaScript on your device, and the text you paste or open is not sent to SavvyToolz. The code editor component (Monaco) is loaded from the jsDelivr CDN: your JSON is not part of those requests, though the CDN sees ordinary request details such as your IP address. Analytics record only that a format or minify action happened, never the content.
Frequently Asked Questions
- Is this JSON Formatter free to use?
- Yes, this JSON Formatter and Validator is 100% free to use.
- Is my data safe?
- Yes. Your JSON is parsed, formatted and converted in your browser and is not sent to SavvyToolz. The code editor component is loaded from the jsDelivr CDN, but your JSON is not part of those requests.
- Can I convert JSON to other formats?
- Yes! Our tool supports converting JSON to XML and YAML.
- How do I fix invalid JSON?
- You can use the 'Fix' button to automatically attempt to repair common JSON errors.
- Does it support large files?
- There is no fixed size limit. Large files are limited by your device memory and browser, and the tree view shows long arrays and objects 50 items at a time so big documents stay responsive.