Developer Tools
JSON Formatter & Validator
Format, beautify, validate and minify JSON — with clear line and column error messages and optional key sorting.
How to use
- 1Paste your JSON.
- 2Choose an indent or Minify; errors show the exact line and column to fix.
Frequently asked questions
Why is my JSON invalid?
The usual culprits are trailing commas, single quotes instead of double quotes, unquoted keys, and comments — none are allowed in strict JSON.
Is my JSON uploaded?
No. Formatting and validation run in your browser, so it's safe for API responses and config files containing private data.
Does sorting keys change my data?
Only the order of object keys changes, which doesn't affect meaning in JSON. Array order is always preserved.
Why the error messages point at a line and column
Rather than surfacing JavaScript's raw `JSON.parse` error (which only gives a character offset), this tool's parseJson wrapper walks back from that offset to count newlines and compute a line and column, so 'Invalid JSON at line 14, column 3' tells you exactly where to look instead of making you count characters. The usual causes behind that error are the same handful every time: a trailing comma after the last item, single quotes instead of double, unquoted object keys, or a `//` comment — none of which are legal in strict JSON even though all four are common in JavaScript object literals.
Sorting keys is a diffing trick, not a data transform
Turning on 'Sort keys' recursively reorders every object's keys alphabetically while leaving array order untouched — arrays stay positional because order is semantically meaningful there, but object key order never changes what the JSON means. The practical use is diffing: two API responses with identical data but differently ordered keys look different in a text diff; sorting both before comparing makes the real differences visible. For structural comparison instead of text comparison, the JSON Diff tool on this site does that directly.
Minify is the inverse operation, and both run locally
Choosing 'Minify' as the indent collapses the same parsed structure back out with no whitespace, which is what you want before pasting JSON into a URL query string, an environment variable, or anywhere size matters more than readability. Both directions — and the validation — run entirely in your browser via `JSON.parse`/`JSON.stringify`; nothing is transmitted anywhere, so pasting a real API response or a config file with production values and keys is safe from a data-exposure standpoint.
Worked example: JSON Formatter & Validator
Paste `{"b":1,"a":[1,2]}` with the default 2-space indent and you get: { "b": 1, "a": [ 1, 2 ] } Switch indent to Minify and turn on Sort keys with `{ "b": 1, "a": 2 }` as input, and the result is `{"a":2,"b":1}` — note `a` now comes before `b`. Feed in `{ "a": 1, }` (a trailing comma after the last property) and you get a line/column error instead of silently-wrong output, since trailing commas aren't legal JSON.
Arrays keep their order when keys are sorted
Indent opens on 2 spaces. The other choices are 4 spaces, a tab, and minify. Minify is the compact form with no added gaps. Sort keys starts off. When I turn it on, keys are sorted inside every object, including objects nested inside other objects, but the order of items in an array stays exactly as I wrote it. A trailing comma is rejected. When the failure names a character position, that position is shown as a line and a column counted from the start of the line. The result is offered as a download with a json name. An empty box fails rather than producing an empty object.
Related tools
- XML Formatter & Validator
Pretty-print and validate XML with readable indentation, or minify it — errors point to the exact line and column.
- SQL Formatter
Format and beautify SQL queries for PostgreSQL, MySQL, SQL Server, SQLite, BigQuery and more, with uppercase keywords.
- Code Beautifier (HTML, CSS, JavaScript)
Beautify messy or minified HTML, CSS and JavaScript into clean, consistently indented code you can read and edit.
- CSS & HTML Minifier
Minify CSS or HTML to shrink file size — strips comments and whitespace and shows how many bytes you saved.
- YAML ↔ JSON Converter
Convert YAML to JSON and JSON to YAML for Kubernetes, Docker Compose, GitHub Actions and other config files.
- XML ↔ JSON Converter
Convert XML to JSON and JSON back to XML, keeping attributes (as @name) and repeated elements (as arrays).