Skip to content
All guides

A little guidance

How to minify JSON into one line

Remove every space and line break from JSON to make it as small as possible, for an API request, a config value or a URL.

Advertisements

Minify JSON

Shrink the orders to a single line

We switched View to Minify. The 76 lines became one line and the size dropped from 1.4 KB to 0.8 KB.

The orders JSON minified into one long line of text, with Minify selected under View and Indent greyed out.
Minify removes all whitespace; the data is unchanged. View full size
ViewLinesSize
File, 2 spaces761.4 KB
Minify10.8 KB

Minified JSON is exactly what most APIs send.

Repeat this example

  1. Open the JSON.
  2. Choose Minify under View.
  3. Copy the single line, or Save it.

Check the result

The Preview shows one line and the bottom line still says Valid JSON.

A common mistake

Expecting smaller numbers or shorter keys: minifying never changes the data itself.

Open JSON Prettifier

Sources and credits

Sample JSON made for these guides. The bookshop orders, names and emails are invented. Every screenshot shows the real tool working on that JSON.

Open the JSON

Paste it into the editor, or drop or choose a .json file.

Choose Minify

Set View to Minify. The JSON becomes a single line with no extra spaces, shown as text you can still edit; Indent is greyed out because it doesn’t apply. It keeps the same colours as the tree.

Compare the size

The line at the bottom shows the new size. Minifying only removes whitespace, so the data is exactly the same.

Switch back any time

Choose Tree or Plain text to spread it over lines again; both directions are lossless. Copy and Save write what the view shows.

  • JSON Prettifier

    How to pretty print JSON so it is easy to read

    Paste minified JSON into JSON Prettifier, or open a .json file, and it is formatted at once and shown as a coloured tree you can open level by level, or as plain text. Nothing is uploaded.

Advertisements