Formatters

Minify JSON to one compact line

JSON Minifier takes valid JSON and returns it as one compact line, dropping every space, tab and newline that sits outside a string. Developers minify API payloads, config files and stored documents to shave bytes before gzip runs, and to paste whole structures into a single command-line argument. The text is checked with JSON.parse and then rewritten token by token, so string contents, number spelling and large integers are untouched. Invalid input shows an error message instead of broken output.

How to use JSON Minifier

  1. Open JSON Minifier in the Toolbox101 app.
  2. Paste pretty-printed JSON into the Input box: the compact version replaces it in the Output area instantly.
  3. Keep in mind that whitespace outside strings disappears, while whitespace inside string values stays exactly as typed.
  4. Paste invalid JSON and the Output area shows an error message instead of a minified line.
  5. Click Copy to take the single-line JSON, ready for storage, logs, or a command line.

Worked example

JSON Minifier returns the output below for this input.

Input

{
    "name": "toolbox101",
    "version": "1.0",
    "enabled": true,
    "tags": [
        "json",
        "xml",
        "crypto"
    ]
}

Output

{"name":"toolbox101","version":"1.0","enabled":true,"tags":["json","xml","crypto"]}

Check it yourself: open JSON Minifier and enter the same input.

Frequently asked questions

Does minifying remove whitespace inside strings?

No. Whitespace inside string values is data (it can change a message, a key, or an error text), so it is preserved byte for byte. Only the whitespace that JSON permits between tokens, such as indentation and line breaks, is removed.

Is minified JSON still valid JSON?

Yes. The input is checked with JSON.parse first and only the whitespace between tokens is removed, so the output is valid JSON for the same data. Run it through the JSON Formatter to get a readable layout back.

Why should I minify JSON at all?

Every space, tab, and newline in a JSON document is a byte that must be stored or transmitted. Minifying shrinks the payload before gzip gets a chance to compress it, which helps with API request bodies, log lines, cache keys, and documents with tight size limits.

What is the difference between minify and format?

They are opposite passes over the same data. Formatting adds indentation and line breaks for humans; minifying strips them for machines. Both preserve the values exactly, and the two Toolbox101 pages produce outputs that round-trip into each other: format either output again and you get the same document back.

Use JSON Minifier now

Runs in your browser. Nothing you type is uploaded.