Processed entirely on your device — nothing is uploaded
How to use the json formatter
- 1Paste your JSON into the box above.
- 2Choose an indent width.
- 3Press Format to pretty-print, or Minify to strip whitespace.
- 4Copy the result, or read the error if the JSON is invalid.
Why you should not paste API payloads into a random website
The JSON developers most often need to inspect is the JSON that is causing a problem — which means it usually contains real data. Authentication tokens, session identifiers, customer records, internal identifiers, API keys embedded in a config object.
Pasting that into a server-side formatter transmits all of it to a third party. Most such sites are perfectly honest, but the payload has still crossed a boundary it should not have, has probably been logged somewhere, and in many organisations that is a reportable incident regardless of intent.
This formatter parses and re-serialises using the browser's own JSON implementation. There is no request, and you can confirm that by disconnecting from the network after loading the page.
Reading the error messages
Browsers report JSON syntax errors with a character offset, which is close to useless in a 4,000-character payload. This tool converts that offset into a line and column, so you can go straight to the problem.
The commonest causes, roughly in order: a trailing comma after the last element of an object or array, which JSON forbids even though JavaScript allows it. Single quotes instead of double quotes — JSON requires double. Unquoted keys, which again JavaScript tolerates and JSON does not. An unescaped control character or newline inside a string. And JavaScript values that are not JSON at all: undefined, NaN, Infinity, comments, or a function.
One subtle case worth knowing: a mismatched bracket is reported at the point where the parser gives up, which is often well past where the actual mistake is. If the reported location looks structurally fine, look upward for an unclosed brace.
Format or minify
Formatting adds indentation and line breaks so a human can read the structure. Two spaces is the common convention in JavaScript projects and the default here; four is preferred in some Python and Java codebases; tabs suit teams that want everyone to choose their own display width.
Minifying strips every optional character, producing the smallest valid representation. This is what you want for anything going over a network, since JSON compresses well but sending less to begin with is better still. On a large payload the saving is typically 15–25%.
Both operations round-trip through a real parse, so the output is guaranteed to be valid JSON representing exactly the same data. Key order is preserved as the parser encountered it; JSON objects are formally unordered, so do not rely on it if the consumer is strict.
What JSON does not support
Comments, which is the single most common frustration. If you need annotated configuration, JSON5 or YAML are the usual answers — but standard parsers will reject the file.
Trailing commas, as above. Several tools now tolerate them on input, but the specification does not.
Numbers beyond the range JavaScript can represent exactly. Integers above 2^53 lose precision when parsed, which is why APIs increasingly send large identifiers as strings. If you are debugging an ID that changes value on a round trip, this is why.
Dates, which have no native JSON type. They travel as strings, conventionally in ISO 8601 format, and it is entirely up to the application to interpret them.
Frequently asked questions
Is my JSON uploaded?
No. Parsing uses the browser's own JSON implementation. Nothing is transmitted, which makes it safe for payloads containing tokens or customer data.
Why does JSON reject my trailing comma?
JavaScript object literals allow trailing commas; the JSON specification does not. Remove it.
Can JSON contain comments?
No. Use JSON5 or YAML if you need annotated configuration, but standard parsers will reject the result.
Why did my large ID number change?
Integers above 2^53 cannot be represented exactly in JavaScript. APIs generally send large identifiers as strings for this reason.
How much smaller is minified JSON?
Typically 15–25% before compression, depending on how deeply indented the source was.
The error points to a line that looks fine. Why?
A mismatched bracket is reported where the parser fails, which can be well past the actual mistake. Look upward for an unclosed brace.