JSON Minifier for beginners — start here
JSON is a way of writing down information so that both people and programs can read it: labels with values next to them, grouped in braces and square brackets. You meet it in settings files, in saved app data, and in answers sent back by websites. When JSON is written for people to read, it is spread across many lines with indenting, and that is what the JSON Minifier takes away: it packs the same information onto one line, without changing a single value. This guide starts from zero and ends with two examples you can try yourself.
At a glance
What JSON looks like
A piece of JSON is a set of pairs: a label in double quotes, a colon, and a value. The value can be a word in quotes, a number, true or false, a list in square brackets, or another set of pairs in curly braces. A small profile, for example, has a name, Priya Sharma, an age of 28, a city, Pune, and a subscribed flag set to true. Written for people to read, each pair sits on its own line with two spaces in front of it, which makes it easy to scan but adds bytes that carry no information.
What minifying does
Minifying removes the bytes that carry no information: the line breaks, the indenting spaces, and the spaces after colons and commas. It does not remove or change any value. The profile above, written across seven lines, is 81 bytes. Minified, it becomes one line of 64 bytes, so 17 bytes are saved, or 21.0 percent. Read the two versions side by side and you will see the same four labels and the same four values, only packed together.
Your first try: leave the example as it is
Open the tool and look before you touch anything. It already holds a small example: an object with a set to 1 and b set to 2, written across five lines. The result panel already shows the answer: 9 bytes saved, from 22 bytes down to 13 bytes, and the minified result reads {"a":1,"b":2}. That is a complete first result, and it shows the whole idea in miniature: the same data, the same order, no line breaks.
Your second try: a settings file
Now try a file you might actually meet: a small settings file with a theme set to dark, a font size of 14, line numbers switched on, and a list of three add-ons, lint, format and git. Written with two-space indenting across eight lines, it is 106 bytes. Minified, it is 87 bytes, so 19 bytes are saved, or 17.9 percent. Paste it into the tool, watch the output appear on one line, and compare the two: every setting is still there, with the same value it had before.
What stays the same
Three things never change. The values stay the same: Priya Sharma is still Priya Sharma, and 28 is still 28. The order stays the same: the labels come out in the order you wrote them in. And the spaces inside quoted words stay the same: a message reading “hello world” keeps its space, because that space is part of the message. Only the spacing between pieces of data is removed, which is why the result is safe to use anywhere the original was safe.
The common mistake
Beginners often look at the one-line result and think it is broken, because it is hard to read. It is not broken: JSON does not need line breaks or indenting, and a program reads the one-line version exactly as it reads the spread-out version. If you need to read it yourself, paste the minified line into a formatter and it will spread out again. Keep the pretty version for reading and the minified version for sending and storing.
Frequently asked questions
What is JSON?
A way of writing down information as labels with values, grouped in braces and square brackets, so that both people and programs can read it.
What does minifying JSON do?
It removes line breaks, indenting and spaces outside strings, packing the same data onto one line. The values are not changed.
How much does minifying save on a small file?
The default example goes from 22 to 13 bytes, saving 9 bytes, and a small profile goes from 81 to 64 bytes, saving 17 bytes.
Is the one-line result still valid JSON?
Yes. JSON does not need line breaks or indenting, and a program reads the one-line version exactly as it reads the spread-out version.
More guides on the JSON Minifier
- How to use the JSON Minifier — step by step
- JSON Minifier explained with worked examples
- JSON Minifier formula — how it actually works
- Common mistakes people make with the JSON Minifier
- JSON Minifier vs doing it by hand — which is faster?
- JSON Minifier — The Complete Guide
- How to get an accurate result from the JSON Minifier
- JSON Minifier for students — with examples
- JSON Minifier for homeowners and DIYers
Try the JSON Minifier — free, in your browser.