JSON Formatter

Paste JSON, validate it, format it with indentation, or minify it into compact output for APIs and config files.

Runs in your browser Format
Format, validate, and minify JSON locally in your browser.

How to use JSON Formatter

  1. Paste valid JSON into the input box.
  2. Choose Format JSON to pretty-print it.
  3. Choose Minify JSON when compact output is needed.
  4. Copy the result after the status line confirms the JSON parsed successfully.

Why this tool exists

A JSON formatter is one of the fastest ways to understand an API response, configuration object, log payload, or webhook sample. Raw JSON is compact for machines but difficult for people to scan. This tool parses the input locally, reports syntax errors, and prints a readable version with stable indentation.

Clean formatting is not just cosmetic. It helps you compare nested fields, find missing commas, spot unexpected arrays, and copy a predictable snippet into documentation or tests. The minify action does the reverse: it removes unnecessary whitespace when you need compact JSON for an environment variable, API body, or fixture.

The tool is browser-based and does not need a server to parse your text. That is useful for private API samples or internal config fragments. Still, JSON can contain secrets such as tokens, passwords, email addresses, user IDs, and internal URLs. Treat formatted output with the same care as the original input.

Use this page for strict JSON. If your data uses comments, trailing commas, or JavaScript object syntax, it is not valid JSON and will show an error. That strictness is intentional because APIs and machine-readable config usually require valid JSON.

Common examples

  • Format a minified API response: input {"id":42,"tags":["a","b"],"active":true} becomes a 2-space indented block with id, the tags array on its own lines, and active on the last line before the closing brace.
  • Catch a trailing-comma bug: pasting {"name":"x","port":8080,} surfaces a SyntaxError because the comma after 8080 is valid JS but illegal JSON, so you delete it before shipping the config.
  • Watch key reordering: {"2":"b","1":"a","x":"c"} formats as {"1":"a","2":"b","x":"c"}, because integer-like keys are emitted in ascending numeric order first regardless of insertion order — which explains a noisy diff that is not really a data change.

FAQ

Why does my JSON throw a SyntaxError when it looks valid?

Nine times out of ten it is a trailing comma or an unquoted key. [1,2,3,] and {"a":1,} are both legal JavaScript but forbidden by the JSON grammar (RFC 8259), so JSON.parse throws. JSON also rejects single quotes, // and /* */ comments, and the bare tokens NaN and Infinity. The 'position N' offset in the error points to where the parser gave up, not where you went wrong, so the missing comma or unclosed bracket is often several lines earlier.

Will formatting corrupt a 64-bit ID like a Twitter snowflake?

It will if the tool round-trips through JSON.parse. Any integer above Number.MAX_SAFE_INTEGER (2^53 - 1 = 9007199254740991) loses precision silently: 9007199254740993 parses to 9007199254740992 with no error. That is exactly why X/Discord IDs are transported as strings. A correct formatter reformats the raw text at the string level instead of decoding numbers into JS doubles, so big integers survive untouched.

Does pretty-printing or minifying change what my JSON means?

No. Whitespace between tokens (space, tab, LF, CR) is insignificant in JSON, so reformatting only adds or removes it. JSON.stringify(value, null, 2) is the standard 2-space pretty form and JSON.stringify(value) is the minified form; both reparse to identical data. The one thing a formatter must never touch is whitespace inside a string, which is significant. If a beautified result parses differently from the original, the tool has a bug.