Skip to main content
Data Formats

JSON Formatter / Minifier / Validator

Format messy JSON with configurable indentation, minify it for production, sort keys alphabetically, or validate and get the exact line and column of any error.

How it works

The tool parses your input with JSON.parse(). If parsing succeeds, it re-serializes using JSON.stringify() with your chosen indentation. Key sorting re-serializes by recursively sorting object keys alphabetically before stringifying.

When JSON is invalid, the browser's parser throws an error with a position hint. The tool extracts the line and column from that message so you can find the problem quickly.

Common uses

  • API response inspection — paste a minified API response and format it to read it quickly
  • Config files — clean up hand-edited JSON configs before committing
  • Production assets — minify JSON before embedding it in JavaScript or HTML
  • Debug syntax errors — validate JSON from a failed API call and find the exact error position

🔒 Privacy

All JSON processing happens in your browser. Your data is never sent to any server.

Edge cases and limits

  • Trailing commas — not valid in strict JSON (though valid in JavaScript). The validator will flag these.
  • Single quotes — JSON requires double quotes. {'key': 'value'} is not valid JSON.
  • Comments — JSON does not support comments. Use JSONC format elsewhere.
  • Large inputs — the tool handles typical API responses well. Multi-megabyte files may be slow.
  • Unicode escapes\uXXXX sequences in strings are preserved correctly.

FAQ

What is the difference between JSON and JavaScript object literals?

JSON is a strict data format. Keys must be double-quoted strings. Values must be strings, numbers, booleans, null, arrays, or objects. JavaScript object literals allow single quotes, unquoted keys, trailing commas, and comments — none of which are valid JSON.

Does sort keys change the meaning of the JSON?

No. JSON objects are unordered by specification. Sorting keys is purely cosmetic and makes diffing and reading easier. Array order is preserved exactly.

Related tools