engrus

7-Zip plugins\Modern7z

Modern7z is a plugin for the popular 7-Zip archiver. It adds support for the following leading-edge compression methods:

Each of these compression methods can only pack a single file. Multiple files are usually pre-packed into a container like TAR, and then it is compressed with the method. You can also use any of these compression methods as a codec when packing files into a .7z file.

Open ZSTD in 7-Zip

Modern7z also allows you to:

  • unpack files from Zip archives packed using the ZSTD method.
  • unpack files from Zip archives packed using the BROTLI method (this method shows up as "129:v1" in 7-Zip). This method is used, for example, in the palemoon.res file from the Pale Moon browser.
  • unpack and pack jsonlz4 files (these files have the signature "mozLz40").

Installation

The Modern7z distribution package is a Zip file that contains two folders (named "32" and "64") and a ReadMe.txt file. The folders contain the 32-bit and 64-bit versions of Modern7z, respectively. To install Modern7z, first create a folder named "Codecs" in the 7-Zip installation folder. Then copy the files from the "32" or "64" folder, depending on the 7-Zip edition that you are using (32-bit or 64-bit), to the "Codecs" folder. After that, each time you launch 7-Zip, it will automatically find the Modern7z plugin and use it to support the new compression methods.

Usage

To pack a file using an methods supported by Modern7z, select the standard "Add to archive..." 7-Zip command. When the "Add to Archive" dialog box appears, select the archive format you want to use in the "Archive format" field:

Compress to ZSTD in 7-Zip

Each of the methods supported by Modern7z has a very wide compression level range:

Compression methodCompression level range
Zstandard1-22
Brotli0-11
LZ40-12
LZ50-15
Lizard10–19 – FastLZ4 will be used
20–29 – LIZv1 will be used
30–39 – FastLZ4 + Huffman will be used
40–49 – LIZv1 + Huffman will be used
Fast LZMA21-9

As the 7-Zip user interface only allows you to select the values 0, 1, 3, 5, 7, or 9, you have to specify the exact compression level via the "Parameters" field. For example, the string "x=20" means that the compression level is 20.

The 7-Zip user interface doesn’t allow you to directly select the number of CPU threads to be used when packing the files, but you can specify it via the "Parameters" field. For example, the string "mt=4" tells plugin to use 4 CPU threads for compression. If you omit the "mt" parameter, plugin will use as many threads as there are CPU cores in the system.

Random access mode is supported for compressed files. This mode allows you to navigate the contents of a TAR container inside a compressed file without completely unpacking the container. This mode is supported only if the size of an independent block doesn’t exceed 64 MB. (For more details on independent blocks, see the Fine tuning section.)

Usage as a codec

As the 7-Zip user interface doesn’t allow you to directly select an additional compression method to be used when packing files into a .7z file, you have to specify it via the "Parameters" field. Use a string in the format "0=NAME" (where NAME is the internal name of the compression method).

Compression methodInternal name
ZstandardZSTD
BrotliBROTLI
LZ4LZ4
LZ5LZ5
LizardLIZARD
Fast LZMA2FLZMA2
Compress to ZSTD in 7-Zip

For example, the string "0=ZSTD" tells 7-Zip to use Zstandard to compress the files.

You also need to specify the exact compression level via the "Parameters" field (see above).

Fine tuning

The compression algorithms allow you to set additional parameters that have an impact on different compression aspects. If you want to specify any additional parameters, enter them in the "Parameters" field in the format "key=value" (just like you do for Compression level).

You can specify the size as follows: "key=Nx" (where N is a number, and x is a unit of measurement). You can use the following units: b (byte), k (kilobyte), m (megabyte), and g (gigabyte).

Block size

When you compress files using the Brotli algorithm as a codec, or the Zstandard, LZ4, LZ5, or Lizard algorithm as a codec or to create a single file, the input stream is divided into blocks of equal size, and each block is compressed separately. This approach allows you to compress data faster by compressing each block in a separate thread. However, it reduces the overall compression level.

By default, the block size is set according to the selected compression level:

Compression levelBlock size
ZstandardBrotliLZ4LZ5Lizard
0-20-10-10-110-11, 20-21, 30-31, 40-411 MB
3-52-32-32-312, 22, 32, 422 MB
6-104-54-54-513, 23, 33, 434 MB
11-1566-76-714, 24, 34, 448 MB
16-17788-915, 25, 35, 4516 MB
18-198910-1116, 26, 36, 4632 MB
2091012-1317, 27, 37, 4764 MB
2110111418, 28, 38, 48128 MB
2211121519, 29, 39, 49256 MB

You can set the block size using the "c" key. For example, the string "c=512m" sets the block size to 512 MB. The string "c=0b" has a special meaning. It instructs the archiver not to split the input stream into blocks and disables multi-threaded compression. (Note: This string doesn’t affect the Brotli algorithm.) This approach allows you to achieve the maximum compression level, but it is also the slowest one.

LZ4, LZ5, and Lizard

The LZ4, LZ5, and Lizard algorithms allow you to set the dictionary size using the "d" key. By default, the dictionary size is set automatically based on the size of data being packed, but you can select it manually.

Allowed values:

AlgorithmDictionary size
ZSTD64k, 128k, 256k, 512k, 1m, 2m, 4m, 8m, 16m, 32m, 64m, 128m, 256m, 512m, 1g, 2g (x64 only)
LZ464k, 256k, 1m, 4m
LZ564k, 256k, 1m, 4m, 16m, 64m, 256m
Lizard128k, 256k, 1m, 4m, 16m, 64m, 256m

Brotli

When using the Brotli method, you can configure the following additional parameters:

  • Algorithm; use the "a" key
    Allowed values:
    0: In this mode, the compressor doesn’t know anything in advance about the properties of the input.
    1: Compression mode for UTF-8 formatted text input.
    2: Compression mode used in WOFF 2.0.
    Example: a=0
  • Sliding LZ77 window size; use the "d" key
    Allowed value range: 1k – 1g
    The encoder may reduce this value, for example, if the input is much smaller than the window size.
    Example: d=256m
  • Input block size; use the "mem" key
    Allowed value range: 1k – 16m
    The encoder may reduce this value, for example, if the input is much smaller than the input block size.
    A bigger input block size allows you to achieve a higher compression level but consumes more memory.
    Example: mem=256m
  • A flag that affects the usage of the "literal context modeling" format feature; use the "lc" key
    Allowed values: 0, 1
    This flag is a "decoding speed vs compression ratio" trade-off.
    Example: lc=1
  • The number of postfix bits (NPOSTFIX); use the "pb" key
    Allowed values: 0, 1, 2, 3
    The encoder may change this value.
    Example: pb=0
  • The number of direct distance codes; use the "fb" key
    Allowed value range: 0 – 15 << NPOSTFIX in steps of 1 << NPOSTFIX
    The encoder may change this value.

Fast LZMA2

When using the Fast LZMA2 method, you can configure the following additional parameters:

  • Algorithm; use the "a" key
    Allowed values: 1 (fast), 2 (optimize), 3 (hybrid mode)
    Example: a=3
  • Dictionary size; use the "d" key
    Allowed value range: 1m – 128m for the 32-bit plugin version; 1m – 1g for the 64-bit plugin version.
    Example: d=64m
  • The number of fast bytes; use the "fb" key
    Allowed value range: 5-273
    Example: fb=160
  • Match finder cycles; use the "mc" key
    Allowed value range: 0-1000000000
    Example: mc=1000
  • The number of literal context bits; use the "lc" key
    Allowed value range: 0-4
    Example: lc=3
  • The number of literal pos bits; use the "lp" key
    Allowed value range: 0-4
    Example: lp=0
  • The number of pos bits; use the "pb" key
    Allowed value range: 0-4
    Example: pb=2

For more details about the meaning of the keys, read the 7-Zip help (see the section about the LZMA and LZMA2 compression algorithms).

Current version

  • Plugin version: 1.9
  • Distribution package size: 2690 KB
  • Distribution package release date: 07 Dec 2023

Note for software developers

If you are going to add support for Modern7z into your software, surely you would like to improve your users’ experience. Modern7z supports the 7z Parameter API, which you can use to eliminate the need for manually entering the compression parameters. Thanks to the 7z Parameter API, your software can use any new 7-Zip plugin that supports the API and automatically display any modifiable parameters in a user-friendly manner based only on the data sent by the plugin.

Additional information

All the compression methods supported by the Modern7z plugin are available in TC4Shell. It is a Windows application that allows you to open many different archives directly in Explorer, just like regular folders. TC4Shell can also modify existing archives and create new ones.

Pack to ZSTD format Pack to ZSTD format Open ZSTD in Windows Explorer

Read more...