JSON Formatter & Validator
Paste JSON below to validate it live, then pretty-print it with your choice of indent size or minify it to a single line.
How JSON Formatter & Validator Works
JSON is meant to be read by machines, which means the compact, whitespace-free JSON an API actually sends is often hard for a human to read, while hand-written JSON often has a small syntax slip (a trailing comma, an unquoted key) that's tedious to spot by eye. This tool validates your JSON live, pretty-prints it with readable indentation, or minifies it back down to a single line -- and points to the exact line and column where anything breaks.
Formula & Method
The tool relies on the browser's own JSON.parse to validate and parse your input -- if parsing succeeds, JSON.stringify re-serializes it either with your chosen indent size (pretty-print) or with no whitespace at all (minify). If parsing fails, the error message's character position is converted into a line and column number by counting newlines up to that point in your original text, so you can jump straight to the problem instead of scanning the whole document.
Worked Example
Pasting {"name": "Clickulate", "tools": 70,} (note the trailing comma before the closing brace) reports a syntax error rather than silently accepting it -- trailing commas are valid in JavaScript object literals but explicitly disallowed in the stricter JSON specification, which is exactly the kind of mistake this tool is meant to catch before it reaches a system that enforces the spec strictly.
Frequently Asked Questions
- Why does my JSON fail here but work fine in JavaScript code?
- JSON and JavaScript object literal syntax look almost identical but aren't the same thing -- JSON requires double-quoted keys, disallows trailing commas, and doesn't support comments or single quotes, all of which JavaScript itself tolerates in an object literal. This tool validates against the strict JSON spec, which is what APIs, config files, and most JSON parsers actually enforce.
- What do the "Total Keys," "Array Items," and "Max Nesting Depth" stats tell me?
- They're a quick structural summary of your parsed JSON -- useful for sanity-checking an API response or config file at a glance (is this the size and shape I expected?) without having to manually count braces and brackets in a large or deeply nested document.
- What's the practical difference between pretty-print and minify?
- Pretty-print adds line breaks and indentation purely for human readability -- useful when inspecting or editing JSON by hand. Minify strips all non-essential whitespace to produce the smallest valid representation -- useful when the JSON needs to travel over a network or be embedded somewhere size matters, since whitespace serves no functional purpose in JSON.
- Does this tool send my JSON anywhere?
- No -- parsing, validation, and formatting all happen locally in your browser using built-in JavaScript functions; nothing you paste here is transmitted anywhere, which matters if your JSON contains sensitive data like API responses with real user information.