What minifying removes, and what it keeps
Minifying JSON means deleting the white space that is only there for people: indentation, line breaks, and spaces after colons and commas. The data stays the same.
- Spaces inside strings stay, including line break escapes such as
\n. - Numbers stay as written.
1.0stays1.0and1E+5stays1E+5. Tools that read the JSON into values and write it back shorten them, which changes the text of your data. Removing white space does not. - Property order stays as written, unless you turn on sorting.
- Duplicate keys stay, with a warning, because deleting one would change the data.
Because the JSON is read in full first, a missing comma or a stray quote is reported with its line and column, and you do not get half a result.
When to minify and when to leave it readable
Minify when the text is sent or stored somewhere that costs per byte: a request body, a value in an environment variable, a cookie, local storage, a query parameter, or text you encode into a QR code.
Leave it readable when people edit or review the file. A minified file is one long line, so every change shows up as a change to the whole line in version control. Format files that live in a repository, and minify at build time if you need to.
On the network the gain is smaller than it looks, because servers usually compress responses with gzip or Brotli, and compression handles repeated white space well. Minifying helps most where text is stored or sent without compression.
Getting readable JSON back
Open the JSON formatter and paste the minified text to indent it again. You get a readable layout, though not your original indentation.
Two things cannot be undone: sorted property order, and comments removed by the relaxed mode. Keep the original if you need either.