JSON Formatter

Format, validate and minify JSON instantly. Syntax highlighting, error detection, and key sorting.

Format & Validate JSON

0 chars
Output will appear here
"key":"value"numberbooleannull

Beautify vs minify vs validate

These three operations sound similar but solve different problems. Beautifying (also called pretty-printing or formatting) adds consistent indentation and line breaks so a human can read the structure at a glance — ideal when you are debugging an API response or reviewing a config file. Minifying does the opposite: it strips every non-essential space and newline to produce the smallest valid JSON, which matters for payloads sent over the wire, embedded in HTML, or stored at scale where every byte counts. Validatingsimply checks that the text is well-formed JSON and pinpoints the first place it breaks. This tool does all three at once — as soon as you paste, it parses your input, reports any error with its position, and then formats or minifies the result. The Tree, TypeScript and Escape modes build on the same parse step, so a document that validates cleanly will work across every mode.

Common JSON syntax errors and how to fix them

Most JSON errors come from a handful of mistakes. Trailing commas — a comma after the last item in an object or array — are valid in JavaScript but illegal in JSON; delete them. Single quotes are not allowed: keys and string values must use double quotes. Unquoted keys like {name: "x"} must become {"name": "x"}. Comments (// or /* */) are not part of the spec and will throw. Other frequent culprits are unescaped control characters or quotes inside strings, a missing closing brace or bracket, and using NaN, Infinity, or undefined, none of which JSON supports. When the validator flags an error, read the character position it reports and look just before it — the real problem is often on the previous line, such as a missing comma between two properties.

JSON vs JSON5 vs JSONC

Standard JSON (RFC 8259) is deliberately strict, which is what makes it a reliable data interchange format. JSONC (“JSON with Comments”) is the variant popularised by Visual Studio Code for config files such as tsconfig.json; it allows // and /* */ comments and trailing commas, but is otherwise JSON. JSON5 goes further, adding unquoted keys, single-quoted strings, hexadecimal numbers, multi-line strings, and leading or trailing decimal points — making it pleasant to hand-edit but no longer plain JSON. The key thing to remember is that neither JSON5 nor JSONC is valid JSON, so they will not parse here and most APIs will reject them. Use them only where a tool explicitly supports them, such as editor and build configuration, and convert to strict JSON for anything sent between systems. The Escape mode above is handy when you need to embed a JSON document inside another JSON string, doubling up the quotes correctly.

Frequently Asked Questions

Find this useful?

These tools are free and ad-free. Support the project!

Buy me a coffee

Related Tools