Home › Generators › JSON Minifier
JSON Minifier
This free JSON minifier shrinks any JSON document down to a single line, so it takes up less space and loads faster. Paste your JSON, press Minify, and copy or download the result. The same tool can also beautify JSON back into readable, indented text, sort object keys alphabetically, and point out exactly where invalid JSON goes wrong — with a line and column number instead of a cryptic error.
How it works
JSON, short for JavaScript Object Notation, is a plain-text way of storing structured data: objects with named keys, arrays, strings, numbers, and true, false, and null values. When people write JSON by hand, they spread it over many lines with indentation so it is easy to read. Machines do not need any of that. In JSON, whitespace between tokens — the spaces after colons, the line breaks between entries — is optional. A JSON minifier takes advantage of that: it parses the document, then writes it back with every unnecessary whitespace character removed. The result is one long line that means exactly the same thing as the original, but is smaller.
To use this tool, paste JSON into the top box and choose an output mode. Minify produces the single-line form, which is what you want before saving a file, sending data to an API, or embedding JSON in a web page. Beautify does the reverse: it spreads the JSON over many lines with either 2-space or 4-space indentation, which is what you want when you need to read or edit a minified file. Tick Sort object keys alphabetically and the tool reorders the keys inside every object, including nested ones, from A to Z. Sorting never changes a value; it only changes key order, which makes it easy to compare two JSON files and spot real differences instead of order differences.
Before producing any output, the tool parses your input with the browser's built-in JSON parser. If the input is valid, you get your result plus a size report: the original byte count, the result byte count, and the percentage saved. If the input is invalid, nothing is overwritten with a fake result. Instead, you get a friendly error that names the line and column where the parser stopped, plus a hint about the most common cause. The usual suspects are a trailing comma after the last item in an object or array, a missing closing quote or bracket, single quotes instead of double quotes around a string, or an unquoted key. Fix the spot the error points to and run it again.
You can also upload a .json file instead of pasting, which is handy for larger documents, and download the result as a .json file when you are done. Everything runs in your browser: your JSON is never sent to a server, stored, or shared, so it is safe to minify configuration files, API responses, and test data here.
Worked example
A developer has a small settings file that is nicely formatted but takes up more space than it needs to:
{
"name": "Ada",
"age": 36,
"city": "Chicago",
"skills": ["Python", "SQL"]
}
Step 1: Paste the JSON above into the input box (or press Load Sample — it is already filled in).
Step 2: Leave the mode on Minify (single line) and press Minify JSON.
The tool parses the input, confirms it is valid, and outputs {"name":"Ada","age":36,"city":"Chicago","skills":["Python","SQL"]} — exactly 66 bytes. That is 30 bytes smaller than the original, a saving of 31.3%. The data is unchanged: the name is still Ada, the age is still 36, and the skills list still holds Python and SQL. Pressing Beautify with 2-space indent turns that single line straight back into the original 7-line layout.
FAQ
What does a JSON minifier do?
A JSON minifier removes all unnecessary whitespace — spaces, tabs, and line breaks — from a JSON document, leaving a single line of valid JSON. The data stays exactly the same; only the formatting changes. Minified JSON is smaller, so it downloads faster and takes up less space in files and API responses.
Is minified JSON still valid JSON?
Yes. Whitespace between JSON tokens is optional, so removing it never changes the meaning of the document. A minified file parses to the exact same values as the original. This tool parses your input first and only outputs minified text when the input is valid, so the result is always valid JSON.
How do I find the error in my JSON?
Paste your JSON and press Minify or Beautify. If the input is not valid, this tool shows a friendly error message with the line and column where the parser stopped, plus a short hint about the most common cause, such as a trailing comma or a missing quote. Fix that spot and try again.
What is the difference between minify and beautify?
Minify squeezes JSON onto a single line with no extra whitespace, which is best for saving space and sending data over a network. Beautify does the opposite: it spreads JSON over many lines with indentation, which is best for reading and editing. This tool offers both, with a choice of 2-space or 4-space indentation for beautified output.
Does the sort keys option change my data?
Sorting keys only changes the order in which keys appear inside each object; it never changes a value. The sorted document still parses to the same data. Sorting is useful when you want to compare two JSON files, because two files with the same data in a different order become identical once their keys are sorted.