StackPractices

JSON Formatter, Validator & Diff

Format, validate and compare JSON with exact error locations and a semantic diff that understands structure — not just lines. Everything runs in your browser: your data never leaves your machine.

1. Input
2. Options

Formatted output

 

Why a semantic diff instead of a text diff?

Text diff tools compare line by line — useless for JSON, where reformatting or reordering keys produces hundreds of phantom changes. This diff parses both documents and compares their structure: it reports that user.roles[1] changed from "editor" to "admin", that config.timeout was added, and that legacy.field was removed. Exactly what you need when reviewing API responses, config changes or fixture updates.

The five errors behind 90% of invalid JSON

Mistake Invalid Valid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 1}{"a": 1}
Unquoted keys{a: 1}{"a": 1}
Comments{"a": 1} // note{"a": 1}
undefined / NaN{"a": undefined}{"a": null}

JSON is deliberately strict: double quotes only, no comments, no trailing commas, and only six types — string, number, boolean, null, object and array. If your input comes from JavaScript code, watch for undefined, NaN and Infinity, none of which exist in JSON. If it comes from a config format like JSON5 or YAML, convert it first.

Your JSON never leaves the browser

Most online formatters send everything you paste to a server — a real problem when the payload contains tokens, customer data or internal URLs. This tool is a static page with no backend: parsing, formatting and diffing run in JavaScript on your machine. Open your browser's network tab and watch — nothing is transmitted. That makes it safe for API responses with secrets, production config dumps and incident data.

Related resources