JSON Formatter
Pretty-print, minify, or validate. Parse errors report the character position instead of a generic message.
—
Worked example
Valid JSON is a stricter format than JavaScript object literals: no trailing commas, no comments, no single quotes, and every key must be a double-quoted string. Each of those produces a parse error that looks mysterious in a browser console.
JSON formatting is cosmetic; JSON validation is the useful half. A parser that tells you where it stopped saves the fifteen minutes of staring at a minified one-line payload from an API.
Reading a parse error
The position is a character offset, not a line number. This page shows the surrounding text with newlines marked so the location is visible. The most common causes, in order: a trailing comma, a single-quoted string, an unquoted key, and a control character pasted from a word processor.
Minifying
Removing whitespace typically cuts a JSON payload by 15–25%. That matters for network transfer and does not matter at all for readability, so minify at the boundary where it is sent, not where it is stored.
Sorting keys
Key order is not significant in JSON but it is significant for diffing. Sorting recursively makes two payloads from different sources comparable, and turns a noisy diff into a readable one.