My Tool Studio
Developer

JSON Minifier

This JSON minify tool removes every space, tab and line break that sits outside your strings and returns the same data on one compact line. Paste JSON, drop or upload a .json file, or load one from a URL, press Minify, then copy or download the result. Numbers are copied exactly as written, so long IDs and values like 1.0 do not change. The line under the panes shows the size before and after in bytes. Other output modes give an escaped string for embedding in code or another JSON field, or a beautified version. Options sort keys A to Z and strip comments and trailing commas before minifying. Invalid input is flagged on its line instead of being half-minified. It all runs in your browser.

Always freeNo sign upRuns in your browser
Output
Sort keys
The result appears here.

How to use

01

Add your JSON

Paste formatted JSON into the JSON box, drop a file on it, press Upload .json or Load URL, or press Try sample to see a small indented object.

02

Pick the output and options

Choose Minified JSON, Escaped string or Beautified. Turn on Sort keys or Remove comments and trailing commas first if you need them, then press Minify, or tick Minify as you type.

03

Copy or download

Press Copy above the result, or Download to save a .min.json file (.txt for an escaped string). Check the byte counts under the panes to see how much smaller it got.

Why JSON Minifier

Before and after: how many bytes minifying saves

Here is the tool's sample record, a product with an id, name, price, stock flag and two tags, saved with different indentation and then minified. The byte counts are exact UTF-8 sizes, the same figures the tool shows under the panes.

The saving comes only from whitespace, so it grows with the indent width and the depth of nesting. The escaped string is larger than the minified JSON because every double quote gains a backslash, plus the two surrounding quotes.

Minifying does not reorder keys or change values, so you can check the output by pasting it into the JSON Formatter and comparing it with your original.

VersionSizeChange vs 2-space
Indented with 4 spaces141 bytes+17%
Indented with 2 spaces121 bytesbaseline
Indented with tabs111 bytes-8%
Minified JSON87 bytes-28%
Minified, as an escaped string105 bytes-13%

Minify, escaped string or beautified: which output to pick

The three output modes start from the same parsed JSON and differ only in how it is written. Pick the one that matches where the JSON is going next.

OutputLooks likeUse it for
Minified JSON{"id":1042,"tags":["a"]}API bodies, config values, smaller files
Escaped string"{\"id\":1042,\"tags\":[\"a\"]}"A JSON document stored inside another string or JSON field
BeautifiedIndented with 2 spaces, one key per lineReading or reviewing the same data

Common questions

Does minifying JSON change the data?
No. Only the whitespace between tokens is removed. Keys, order, values and spaces inside strings stay the same, and numbers are copied character for character, so 1.0 stays 1.0 and 1e3 stays 1e3. The one exception is Sort keys: sorting has to parse the data, so numbers are then re-printed the JavaScript way.
How much smaller does JSON get when minified?
It depends on how much indentation the file had. Deeply nested JSON with 4-space indents shrinks more than JSON that was already compact, and the tool shows the exact bytes for your file. If your server gzips responses, the saving over the network is smaller, because whitespace compresses well.
Is minified JSON faster to parse?
A little, since there are fewer characters to read, but the difference is usually small. The main gain is fewer bytes to store and send. Parsing speed depends far more on the size of the actual data.
How do I minify a large JSON file?
Press Upload .json, or drop the file on the JSON box, and it is read and minified in your browser. Very large files are limited by your device's memory and can make the tab slow. For those, the command jq -c . file.json does the same job on the command line.
What is the difference between minify and stringify for JSON?
Minify removes whitespace, and the result is still a JSON object or array. Stringify, which is the Escaped string option here, wraps that minified JSON in double quotes and escapes the quotes and backslashes inside it. Use the escaped form when the JSON has to live inside another string, such as a field in a larger JSON document.
How do I turn minified JSON back into readable JSON?
Switch Output to Beautified here and press the button again, or paste it into the JSON Formatter, which also offers other indent widths, a tree view and key sorting. The data is identical either way.
Why does the JSON minifier say my JSON is invalid?
The input has to parse before it can be minified. The problem line is highlighted, and the message gives the line, column and reason. For comments, trailing commas and single quotes, press Clean and retry, which turns on the clean-first option and minifies again.
Does minifying JSON remove comments?
Only if you ask it to. JSON does not allow comments, so JSON with comments normally fails to parse. Tick Remove comments and trailing commas first and the minifier strips // and /* */ comments, trailing commas and single quotes before it minifies.
Is my file uploaded when I use Upload .json on the minifier?
No. The button opens the file inside your browser tab and the minifying happens there too. Only Load URL involves a server: the site fetches that public address for you, because browsers block most cross-site reads.

More Developer tools

View all