JSON Formatter
Format, validate and minify JSON data with syntax highlighting.
Format, validate and minify JSON data with syntax highlighting.
It has happened to every developer. You call an API, log the raw response, paste it into your code — and something breaks. Or you open a configuration file that was hand-edited by a colleague and it fails to parse. The JSON is a single unbroken line, 4,000 characters wide, and the parser error just says "unexpected token at position 1,847."
A JSON formatter solves this in one paste: it adds proper indentation so the structure becomes visible, and it pinpoints exactly where the syntax error is rather than leaving you to count characters manually.
JSON has strict syntax rules that trip up even experienced developers, especially when JSON is written by hand or generated by tools that do not enforce the spec:
{"a": 1, "b": 2,} — JavaScript allows trailing commas in objects and arrays; JSON does not. This is probably the most frequent error in hand-written JSON.{'key': 'value'} is valid JavaScript but invalid JSON.{key: "value"} is valid in JavaScript object literals but not in JSON. All keys must be quoted strings."C:\Users\name" must be written as "C:\Users\name".// this is a comment or /* block comment */ will cause a parse failure. If you need comments in a config file, consider JSONC or YAML instead.{"port": "8080"} and {"port": 8080} are both valid JSON but have different types — many APIs are strict about this distinction.Formatting adds indentation (typically 2 or 4 spaces per level) and line breaks, making the structure human-readable. Use it whenever you are reading or debugging JSON.
Minifying strips all whitespace that is not inside string values, producing the most compact representation. Use minified JSON in production API responses and configuration files where every byte matters — a formatted JSON file can be 30–50% larger than its minified equivalent purely due to whitespace.
Crucially, formatted and minified JSON are semantically identical. The data they represent is exactly the same; only the presentation differs. Any JSON parser will produce the same in-memory structure from both forms.
Complex API responses often nest objects several levels deep — a user object containing an address object containing a coordinates object. After formatting, use the tree view or collapsible sections (if your formatter supports them) to collapse subtrees you do not need to inspect. This lets you focus on the part of the structure that is relevant to your debugging task without losing the overall context.
No. Formatted and minified JSON are semantically identical — every JSON parser produces the same data structure from both. The only practical difference is file size and human readability. Minified JSON saves bandwidth and storage; formatted JSON is easier to inspect and debug.
JSON was designed as a strict, language-agnostic data format — not as JavaScript syntax. Douglas Crockford, who formalised the JSON spec, deliberately excluded trailing commas to ensure unambiguous parsing across all languages and platforms. JavaScript later relaxed this rule for its own object literals, but JSON itself has never changed.
JSON does not support comments per the spec. If your file uses comments, it is likely JSONC (JSON with Comments), which is used by VS Code configuration files and TypeScript config. You can strip comments manually or use a JSONC-aware parser. This formatter validates against the standard JSON spec, so commented JSON will show as invalid.
Literal newlines cannot appear inside JSON string values — they must be represented as the escape sequence \n. Similarly, tabs must be \t, carriage returns must be \r, and double quotes must be \". If you see an "unterminated string" error, check whether your string values contain unescaped control characters.