On-device AI — professional-grade, fully private.

Documents

JSON Minifier: How to Minify JSON Online and How Much Smaller It Gets

Minify JSON online: what a JSON minifier removes, how much smaller files really get before and after gzip, and when to compress JSON and when to leave it.

Updated November 8, 20267 min read

To minify JSON, paste it or drop the file into the JSON minifier and press Minify. The tool removes the spaces, tabs and line breaks between tokens, so the whole document becomes one compact line, and it shows you the size before, the size after and the percent saved. Your data is not changed: every string, number and key comes out exactly as you wrote it. How much smaller the file gets depends on how it was indented. In our test a 2-space pretty-printed file lost 47% of its bytes, but only 3% once both versions were gzipped. That second number is the one that matters for most web traffic, and it is why this guide also covers when minifying is worth doing and when it is not.

What a JSON minifier removes

JSON allows exactly four whitespace characters between tokens: space, tab, carriage return and line feed. A pretty-printed file uses them for indentation, the line break after every comma and the space after every colon. None of them carries data, so a minifier can drop all of them and any program reading the file gets the same result.

Part of the fileWhat the minifier doesWhy
Indentation and line breaksRemovedPure formatting
Space after a colon or commaRemovedPure formatting
Spaces inside a string, such as "John Smith"Kept exactlyThey are part of the value
Numbers like 1.50 or a 19-digit IDKept digit for digitRewriting a number can round it
Key order and repeated keysKept as writtenNo object is rebuilt
Comments and a trailing comma (Relaxed mode only)RemovedTurns JSONC into strict JSON

The last rows matter more than they look. Many minifiers read your JSON into values and print them again. That rounds any integer past 9,007,199,254,740,991, turns 1.50 into 1.5, collapses repeated keys to the last one and moves number-like keys to the front. This minifier copies each token through untouched, so none of that happens. If the input was already minified, the output is identical to it and the tool reports 0% saved.

How to minify JSON online, step by step

1

Add the JSON

Open the JSON minifier and paste into the box, or drop a file. It opens .json, .jsonc, .ndjson, .jsonl, .geojson, .har, .map, .webmanifest and .txt, in UTF-8 or UTF-16.

2

Choose the dialect

Strict JSON is the default. Pick Relaxed (JSONC) for config files with // or /* */ comments or a trailing comma; both are removed. Tick JSON Lines for log or dataset files with one document per line; each line is minified on its own and the line breaks between records stay.

3

Decide on the two options

Measure gzipped size is on by default and adds a second line of numbers. Shorten \uXXXX escapes is off by default; turn it on only if you want escaped characters written directly (see below).

4

Press Minify

The file is processed on your device with a progress count and a working Cancel. Each file card shows raw size before and after with the percent saved, then the gzipped sizes.

5

Download or copy

Download saves the result as yourfile.min.json (or .min.ndjson for JSON Lines). Copy result puts it on the clipboard.

Lossless minification with raw and gzipped savings, Strict, Relaxed and JSON Lines modes. Free: one file at a time up to 25 MB, every mode and option included. Pro: up to 20 files at once in one ZIP. It all runs on your device, not our servers.

Minify JSON

How much smaller does minified JSON get?

We took one test document, an API-style list of 500 customer records with nested addresses and orders, and saved it four ways. The data is identical in every row; only the whitespace differs.

Saved asRaw sizeMinifiedRaw savingGzipped before → afterGzipped saving
Tab indent153.7 KB100.7 KB34%11.2 KB → 10.4 KB7%
2-space indent190.2 KB100.7 KB47%10.7 KB → 10.4 KB3%
4-space indent263.2 KB100.7 KB62%12.6 KB → 10.4 KB17%
Already minified100.7 KB100.7 KB0%10.4 KB → 10.4 KB0%

Two things stand out. First, the raw saving is all about indentation: deeper nesting and wider indents mean more spaces to remove, which is why 4-space files shrink the most. Second, gzip had already squeezed most of that whitespace out, because long runs of identical spaces are the easiest thing there is to compress. With brotli, which many servers use, the minified and 2-space versions came out within about 50 bytes of each other in our test. Your own numbers will differ, so read the two lines the tool shows for your file instead of trusting a general percentage.

If you need a file much smaller than minifying makes it, remove what you do not need. Dropping unused fields with Remove JSON Keys often saves more than whitespace ever could, because it removes data rather than formatting.

When to minify JSON

SituationMinify?Reason
API response sent with gzip or brotliOptionalUsually a few percent after compression, but less text to parse
Request body posted from a device that does not compressYesThe raw saving is the real saving
JSON embedded in a web page, script or app bundleYesOften stored and shipped uncompressed
JSON stored in a database column or a cacheYesStorage counts raw bytes
Config file read from disk (manifest, settings)UsuallySmaller file, nothing lost, but see below
Large log or dataset in JSON LinesYes, with JSON Lines onKeeps one record per line for other tools

The common thread: minify when the bytes travel or sit somewhere without compression, or when a program reads the file many times. Smaller text is also less work for every parser that walks it, on every request, which is a cost compression does not remove.

When not to minify

  • Files people edit by hand. A minified tsconfig.json or settings file is one long line that nobody can review. Keep the source readable and minify a copy for shipping.
  • Files under version control. A one-line file turns every change into a diff of the whole document. Commit the formatted version; minify at build or export time.
  • Config with comments you need. Relaxed mode removes comments as part of minifying, so the notes explaining a setting are gone from the output. Keep the original.
  • Debugging an API. Read the response formatted. If you only have a minified one, paste it into the JSON formatter to get the outline back.
  • When gzip already did the job. If the gzipped line barely moves for your file, minifying is not the change that will make the page faster.

Shortening \u escapes, and other options

Some JSON writers escape every non-ASCII character, so the Chinese word 你好 is stored as \u4f60\u597d: twelve bytes where six would do in UTF-8. Shorten \uXXXX escapes writes such characters directly. Every parser reads both forms as the same string, so the meaning does not change, but the bytes do, which is why it is off by default. It is the biggest win on files full of CJK text or emoji. It never converts an escaped quote, backslash or control character, because writing those directly would break the file.

Turning off Measure gzipped size skips two compression passes, which helps only on very large files. It does not change the output.

Large files and several files at once

Free handles one file at a time up to 25 MB, with every mode and option. The page stays responsive while the file is scanned, and you can cancel. Pro adds batches of up to 20 files, each with its own before-and-after numbers, collected into one ZIP, and raises the per-file size to whatever your device can handle. To check a payload is valid before you ship it, run it through the JSON validator; to put minified JSON inside a string in code or another JSON document, use JSON Escape.

Frequently asked questions

How do I minify JSON online?

Paste the JSON or drop the file into the minifier, keep Strict JSON or pick Relaxed for files with comments, press Minify, then download or copy the result. Free covers one file up to 25 MB.

Does minifying JSON change the data?

No. Only whitespace between tokens is removed. Strings, numbers, key order and repeated keys come out exactly as written, so long IDs and values like 1.50 are not rounded. A program reading the minified file gets the same data.

How much does minifying compress JSON?

It depends on the indentation. In our test the same data shrank 34% from a tab-indented file, 47% from 2 spaces and 62% from 4 spaces. After gzip the saving was 3% to 17%, because gzip already compresses whitespace well.

Is minifying JSON the same as gzip compression?

No. Minifying removes characters and the result is still plain JSON any program can read. Gzip encodes the bytes and must be decompressed first. They work together: servers usually gzip the minified file.

Can I minify JSON with comments, like tsconfig.json?

Yes. Choose Relaxed (JSONC). It accepts // and /* */ comments and a trailing comma and removes them, so the output is strict JSON. Keep your original if you need the comments.

Why did my JSON get 0% smaller?

It was already minified: there is no whitespace left between tokens to remove. The output is identical to the input. To make it smaller, remove fields you do not need.

Keep reading

More in Documents →