7-Zip Command Line: Set Compression Level
This guide explains how to set the compression level in 7-Zip using the command line. You will learn the exact syntax for the compression switch, understand the available compression levels from store to ultra, and see practical examples of how to apply these settings to your archives.
The Compression Level Switch:
-mx
In 7-Zip, the compression level is controlled using the
-mx switch. You can specify a level from 0 (no
compression) to 9 (maximum compression).
The syntax can be written as either -mx[0-9] or
-mx=[0-9].
Available Compression Levels
-mx0(Copy / Store): No compression is applied. Files are simply packaged into the archive container quickly without reducing file size.-mx1(Fastest): Lowest compression ratio, but completes the operation at the fastest speed with minimal CPU usage.-mx3(Fast): Low compression ratio, slightly better than level 1.-mx5(Normal): The default compression level used by 7-Zip if no switch is specified. It offers a balanced ratio of file size reduction to processing speed.-mx7(Maximum): High compression ratio. It requires more system memory (RAM) and CPU time.-mx9(Ultra): The highest possible compression ratio. This produces the smallest file sizes but requires the most time and substantial RAM.
Command Examples
1. Ultra Compression
(-mx9)
To create a .7z archive with the highest compression
level:
7z a -mx9 archive.7z C:\path\to\files\*2. Fast Compression
(-mx1)
To create a quick archive when speed is more important than size:
7z a -mx1 fast_backup.7z C:\path\to\files\*3. No Compression / Store
(-mx0)
To bundle files without any compression:
7z a -mx0 storage.7z C:\path\to\files\*4. Applying to ZIP Archives
The -mx switch works identically when targeting
.zip output:
7z a -tzip -mx9 archive.zip C:\path\to\files\*Important Considerations
- Resource Usage: Higher levels (
-mx7and-mx9) significantly increase memory consumption during both compression and decompression. Ensure the target system has sufficient RAM available. - File Types: Already compressed formats (such as
JPEG, MP4, or PNG) will not shrink significantly, even at level 9. Using
-mx1or-mx0on these formats saves time without losing noticeable space savings.