How this JSON formatter works
JSON (JavaScript Object Notation) is a lightweight text format for storing and transferring structured data. This tool reads your JSON with the browser's built-in parser, so the rules it enforces are exactly the rules every standards-compliant JSON consumer follows: double-quoted keys and strings, no trailing commas, and no comments.
Formatting (beautifying) re-serialises valid JSON with consistent indentation and line breaks, turning a dense one-liner into a readable, nested structure. Minifying does the opposite — it strips every optional space and newline to produce the smallest equivalent payload, which is ideal for network transfer. Validating simply checks whether the text parses, reporting the exact error when it does not.
{"name":"Ada","langs":["Lisp","Ada"],"active":true} formats with 2-space indentation to a 6-line, easy-to-scan block — and minifies back to the same single line. It reports 3 keys, a depth of 2 (the object contains an array), and its byte size. A version with a trailing comma — {"name":"Ada",} — fails validation and shows the parser error instead.When parsing fails, the tool surfaces the browser's own error message and, where the engine provides it, the character position of the problem. Below are the mistakes that trip people up most often.
| Common error | Example | Fix |
|---|---|---|
| Trailing comma | {"a":1,} | Remove the comma after the last item |
| Single quotes | {'a':1} | Use double quotes for keys and strings |
| Unquoted key | {a:1} | Wrap keys in double quotes: {"a":1} |
| Missing comma | {"a":1 "b":2} | Separate items with a comma |
| Comments | {"a":1 // note} | JSON has no comments — remove them |
| Unescaped quote | {"a":"he said "hi""} | Escape inner quotes: \"hi\" |
Reference note: this tool follows the strict JSON grammar (RFC 8259). Formats such as JSON5 or JSONC that allow comments and trailing commas are not valid JSON and will be reported as errors.
Frequently asked questions
- How do I format / beautify JSON?
- Paste your JSON into the box and press Format. The tool parses it and pretty-prints it with consistent indentation (2 spaces by default), adding line breaks and nesting so the structure is easy to read.
- How do I validate JSON?
- Paste your JSON and press Validate. If it is valid you will see a confirmation plus stats for the number of keys, nesting depth and byte size. If it is invalid, the exact parser error message is shown, often with the position of the problem.
- What's the difference between formatting and minifying?
- Formatting (beautifying) adds whitespace and indentation to make JSON readable. Minifying removes every unnecessary space and line break to make the payload as small as possible. Both produce equivalent data.
- Why am I getting a JSON parse error?
- The most common causes are trailing commas after the last item, single quotes instead of double quotes, unquoted object keys, missing commas between items, and stray comments. Strict JSON requires double-quoted keys and strings and no trailing commas.
- Is my JSON uploaded anywhere?
- No. All parsing, formatting, validation and minifying happen locally in your browser. Your JSON is never sent to a server, so it is safe to paste sensitive data.
- How do I minify JSON?
- Paste your JSON and press Minify. The tool re-serialises it with no spaces or line breaks, producing the smallest valid representation of the same data, which you can copy with the Copy button.