JSON Minifier
Minify JSON data to reduce file size
Tip: Paste your JSON data and click Minify to compress it by removing whitespace, reducing file size for faster transmission.
Runs in your browserInput JSON Data
Minify JSON to a single line
Paste JSON or open a .json file and it is minified as you type. The JSON minifier removes every space, tab and line break between keys and values, and the result window shows the size before and after.
Only valid JSON is minified, because the text is first read with the browser's strict JSON parser. If it fails, the result window gives the line and column of the problem, and pressing Minify JSON moves the cursor to that spot.
JSON minify example
The Example button loads this file. Minified, 246 bytes become 200, 19% smaller:
{
"name": "shop-widget",
"version": "2.1.0",
"private": true,
"scripts": {
"build": "vite build",
"test": "vitest run"
},
"keywords": ["cart", "checkout"],
"description": "Two spaces inside a string stay",
"price": 1.50
}
{"name":"shop-widget","version":"2.1.0","private":true,"scripts":{"build":"vite build","test":"vitest run"},"keywords":["cart","checkout"],"description":"Two spaces inside a string stay","price":1.5}
The double space in description is part of a string, so it stays. 1.50 came out as 1.5: the same number, written shorter.
What else minifying rewrites
The minified text is written fresh from the parsed data, not cut out of your input. That has a few side effects:
Written differently
- Numbers in their shortest form:
1.50becomes1.5,1e3becomes1000 - Escapes such as
\u00e9and\/become the plain character; quotes, backslashes and control characters stay escaped - With Sort keys on, the keys of every object in alphabetical order, at every level
Can be lost
- A key that appears twice in one object: only the last value is kept
- Digits of whole numbers above 9007199254740991, the largest a JavaScript number holds exactly
Keys and strings keep their content, and true, false, null and the order of array items stay as they are.
When a JSON compressor is worth it
On the web, most servers already send JSON with gzip or brotli compression, which shrinks repeated spaces to almost nothing. Minifying an API response first still saves a little, but the bigger gain is where nothing compresses the text for you.
That is the case for JSON kept in localStorage or a database column, sent in a query string or a message queue, or pasted into a config field with a length limit. There every removed space counts.
Need to read it again?
The JSON beautifier puts line breaks and indentation back, with 2 spaces, 4 spaces or tabs.
JSON minifier questions
No. A program that reads the minified file gets the same keys, values and array order. Only the spelling of some numbers and escapes changes, and the key order if you turn on Sort keys.
It isn't valid JSON yet. Trailing commas, single quotes, unquoted keys and comments are allowed in JavaScript but not in JSON. Fix the spot the error points to and the result appears.
Click Open file or drop the file on the input window. It is read in your browser, and Download saves the result as a .json file.
No, only the syntax. To test that the data has the right fields and types, see JSON Schema validation.
No. Minifying runs in your browser.