JSON Beautify, Minify and Validate: Error Location, Key Sorting and Escapes

Open Tool JSON Pretty, Minify and Validate

Mode decides the output shape

Beautify re-indents with one key per line for human reading; minify strips structural whitespace for the smallest payload; validate only judges legality and reports location without rewriting. Legality follows the JSON specification: keys in double quotes, no comments, no trailing commas, control characters escaped. Much of what looks like JSON is actually a JavaScript literal, where single quotes, bare keys and comments make a strict parser fail immediately.

Steps

  1. Paste the content or load the sample.
  2. Choose beautify, minify or validate, and an indent of 2, 4, tab or none.
  3. Pick LF or CRLF and a key style of preserved, camel, snake or kebab.
  4. Toggle key sorting, non-ASCII escaping or stripping, and full key path listing.
  5. Process; success returns output, failure returns a line and column. Copy or download.

Using the error location

Parsers report position, not cause, so read around it. Missing commas sit between adjacent members; extra commas trail the last item; mismatched quotes shift everything after them. Positions are one-based and usually point at the offending character or the one before. For deep nesting, extract that fragment and validate it alone. Mojibake points to file encoding, not content — check UTF-8 versus GBK.

Number and escape traps

The spec sets no precision, and implementations use doubles, so integers past about nine quadrillion lose accuracy and big IDs belong in strings. Leading zeros are illegal, while zero followed by a decimal point is fine. Escapes need a doubled backslash, control characters as \u plus four hex digits. Escaping non-ASCII keeps payloads ASCII-safe at the cost of size.

Common problems

Treating comments as legal, when the standard forbids them. Trailing commas after the last element. Single quotes that work in lenient parsers and break across systems. Duplicate keys, where the last silently wins and data disappears. NaN and Infinity, which are not JSON values and must become strings or null. And beautifiers that rewrite strings — proper ones are lexer-aware and leave string contents untouched.

⏫︎