Calculator
What the JSON Minifier does
JSON Minifier: formats Status, Output and Bytes from JSON Input, Indent and Sort keys. Example: indent 2 spaces, sort keys Keep order and action Minify gives status Minified.
Point it at JSON Input, Indent, Sort keys and Action and it returns Status, Output and Bytes. You can nudge a single number and watch the effect straight away.
Most people who open the JSON Minifier are people inspecting an API response. Most of these tasks are one-liners in a terminal, but not when you are away from one.
The work is done by JavaScript already loaded in your browser, so your input never crosses the network.
The sections that follow cover the fields, the method, and one full example computed from the defaults.
What do the JSON Minifier fields mean?
The JSON Minifier uses 4 inputs. Pre-filled inputs double as documentation: each one shows what a reasonable value looks like.
| Field | What to enter | Default |
|---|---|---|
| JSON Input | paste or type any amount of text | [ { "name": "YoursTools", "tools": 801, "categories": ["developer", "finance", "health"], "active": true }, { "name": "Demo App", "tools": 42, "categories": ["math", "converters"], "active": false } ] |
| Indent | choose from 2 spaces, 3 spaces, 4 spaces or Tab | 2 spaces |
| Sort keys | choose from Keep order or A to Z | Keep order |
| Action | choose from Format, Validate or Minify | Minify |
How does the JSON Minifier work?
Each output is derived from the inputs above in a single pass; there is no hidden state carried between runs, so the same inputs always give the same formatted output.
Validation is deliberately strict: silently coercing a bad value is how wrong numbers get trusted.
Worked example
These are the values the JSON Minifier loads by default, and the result it produces from them. This is the worked example the page starts from, reproduced here so you can check the arithmetic.
| JSON Input | [ { "name": "YoursTools", "tools": 801, "ca… |
|---|---|
| Indent | 2 spaces |
| Sort keys | Keep order |
| Action | Minify |
| Status | Minified |
|---|---|
| Output | [{"name":"YoursTools","tools":801,"categories":["developer","finance","health"],"active":true},{"name":"Demo App"… |
| Bytes | 176 |
Minifying
Minifying removes every byte of whitespace that does not change the parsed value. It is lossless with respect to data and irreversible with respect to formatting.
| Removes | spaces, tabs, newlines between tokens | outside of string values |
|---|---|---|
| Preserves | everything inside strings | whitespace in a string is data |
| Typical saving | 10 to 20% before gzip | less after compression |
Worth knowing
- Gzip already eliminates most whitespace redundancy, so the wire saving is smaller than the byte-count saving suggests.
- The real gain at scale is parse time, not transfer size.
- Never minify a file humans maintain. Minify at build or transport time instead.
Read next: JSON Formatting: The Rules People Get Wrong
How to use it
- Paste your content into JSON Input.
- Pick a value for Indent: the options are 2 spaces, 3 spaces, 4 spaces or Tab.
- Pick a value for Sort keys: the options are Keep order or A to Z.
- Pick a value for Action: the options are Format, Validate or Minify.
- The result appears as you type. There is no button to press.
- You get Status, Output and Bytes back.
- Copy Link puts the current inputs in the URL, so bookmarking it brings the same numbers back.
What this tool does not do
- Output follows the common convention for this format; a specific toolchain may have its own house style.
- Processing happens in your browser, so extremely large inputs are bounded by available memory.
- It applies one method. If your situation calls for a different convention, the answer will not match.
Frequently asked questions
Only JSON Input, Indent, Sort keys and Action. Every box already holds a working value, which makes it easy to isolate the effect of a single variable.
With the values loaded when the page opens, status comes out as Minified. The figure is derived from the inputs above, so it updates whenever they do.
It is not stored or transmitted. The calculation happens locally and leaves no trace with us.
No. There is no account, no usage cap and no trial period. The site is funded by advertising rather than by charging for the tools.
It matches what you would get working it out by hand, with fewer opportunities to slip.