Skip to contentSellstamp

JSON formatter

Paste JSON to pretty-print it with 2 or 4 spaces or a tab, or minify it. Invalid JSON gets the line and column of the error and what was expected.

Indent

Parsed and formatted in your browser; nothing you paste is sent anywhere.

Stays on your device

Everything runs in your browser. Nothing you type is sent to Sellstamp or anyone else.

Building something to sell?

Sellstamp has a storefront, a checkout into your own payment account, automatic delivery and an API with webhooks. Open a free store

How to use it

  1. Paste your JSON.
  2. Choose 2 spaces, 4 spaces, a tab, or Minify.
  3. If it is invalid, read the line and column and the reason, and fix that spot.
  4. Copy the result.

What the error actually tells you

Invalid JSON gets the line and column of the first character the grammar cannot accept, and what it expected there. The usual causes are the things JavaScript allows and JSON does not: a trailing comma before a closing bracket, single quotes around a string, an unquoted key, a comment, or a number written .5 or 01. Each of those is named specifically rather than reported as “unexpected token”, because the fix is different for each.

Validity is decided by your browser’s own JSON.parse; the location is worked out separately, only when it fails, so a value that formats here is a value every JSON parser accepts.

What formatting changes, and what it does not

Whitespace and key order are the only things pretty-printing and minifying touch, with one exception worth knowing: numbers are normalised on the way through. 1.0 comes out as 1, 1e2 as 100, and an integer larger than 253 — a 64-bit database id, say — loses its low digits. That is how JavaScript numbers work, not a bug in this tool, and it is also what will happen when that JSON reaches any JavaScript that parses it. If those ids matter, send them as strings.

Everything happens in your browser. What you paste is never sent to Sellstamp, which is also why there is no size limit beyond what your browser can hold.

Questions

How do I validate JSON?

Paste it here: this is also a JSON validator. If your browser’s own JSON.parse accepts it, it is valid JSON and it is formatted. If not, you get the line, the column and what was expected there.

What are the most common JSON errors?

Things JavaScript allows and JSON does not: a trailing comma, single quotes, unquoted keys, comments, and numbers written as .5 or 01.

Why did my large number change?

Integers above 2^53 lose their last digits when parsed as JavaScript numbers, and 1.0 becomes 1. Send large ids as strings if they must survive exactly.

Does formatting change my data?

Only whitespace, apart from the number normalisation above. Key order and values are kept.

Is my JSON sent anywhere?

No. It is parsed and formatted in your browser, which is also why the only size limit is what your browser can hold.