Skip to content
MtrXTools

JSON formatter

Format or minify JSON, find the exact line and column of any error with the likely cause, repair comments and trailing commas, sort keys and browse a tree view. Big numbers keep every digit. Runs in your browser.

What it does

  • Validates as you type, and points to the exact line and column of the first error with the likely cause: a trailing comma, single quotes, an unquoted key, a comment, a missing comma, or an invisible character pasted from a chat app or document.
  • Formats with 2 spaces, 4 spaces or tabs, minifies to one line, and can sort keys alphabetically, which makes two documents easy to compare.
  • Repairs the common near-JSON: JavaScript object literals, config files with comments, and trailing commas.
  • Shows a collapsible tree view, counts keys, objects, arrays and depth, and warns about duplicate keys.
  • Unwraps a JSON string that contains escaped JSON ("{\"a\":1}"), as logs and message queues often produce, and copies output as an escaped string for embedding.

Numbers stay exact

Most online formatters run the input through JavaScript's JSON.parse, which stores numbers as 64-bit floats. Integers above 9,007,199,254,740,991 (2^53 - 1), such as database IDs or Twitter/X snowflake IDs, are silently rounded, so the formatted output no longer matches the input. This formatter keeps every number exactly as written and points out the ones other tools would change.

Questions

Is my JSON uploaded?
No. Parsing and formatting run in your browser, and the input isn't saved or put in the address bar, so it is safe for API responses that contain tokens or personal data.
Why is a trailing comma an error?
The JSON standard (RFC 8259) doesn't allow a comma after the last item, though JavaScript and many config formats do. Strict parsers, including most APIs, reject it. Use Repair to remove them.
What happens with duplicate keys?
JSON allows them, but parsers disagree: most keep the last value, some keep the first, and some reject the document. The formatter keeps both and lists them so you can remove one.
How large a file can it handle?
Several megabytes formats in well under a second on a laptop. The tree view shows the first 3,000 values; the pretty and minified views show everything.