Awesome Open Source
Awesome Open Source

NuGet Badge License: MIT Build Status


A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.

Nuget Packages

Package Name Version Description
EasyCompressor Contains GZip, Deflate and (Brotli available only in .NETCore2.1, .NETStandard2.1 and above)
EasyCompressor.BrotliNET Contains Brotli using Brotli.NET (for erlier than .NETCore2.1, .NETStandard2.1)
EasyCompressor.LZ4 Contains LZ4 using K4os.Compression.LZ4
EasyCompressor.LZMA Contains LZMA using LZMA-SDK
EasyCompressor.Snappy Contains Snappy using Snappy.Standard
EasyCompressor.Zstd Contains Zstd (ZStandard) using ZstdNet
EasyCaching.Extensions.EasyCompressor This integrates EasyCaching with EasyCompressor. (How to use)

Note :

LZ4, GZip, Deflate, Brotli, and LZMA are cross-platform because these are complete implementations with C#. (also BrotliNet too because this is a wrapper of brotli native library for win/linux/osx)

But Zstd and Snappy are not cross-platform, because they are just a wrapper of the native library for windows.


  • Supports and Implements many compression algorithms.
  • Supports async/await and CancellationToken.
  • Supports woking with multiple compressor with specified name
  • Supports Stream as most as possible (depending on the underlying library)
  • Compress/Decompress between byte[], Stream, StreamReader and StreamWriter.

Get Started

1. Install Package

PM> Install-Package EasyCompressor.LZ4

2. Add Services

public void ConfigureServices(IServiceCollection services)

    //or services.AddGZipCompressor();      package : EasyCompressor
    //or services.AddDeflateCompressor();   package : EasyCompressor
    //or services.AddBrotliCompressor();    package : EasyCompressor
    //or services.AddBrotliNetCompressor(); package : EasyCompressor.BrotliNET
    //or services.AddZstdCompressor();      package : EasyCompressor.Zstd
    //or services.AddLZMACompressor();      package : EasyCompressor.LZMA
    //or services.AddSnappyCompressor();    package : EasyCompressor.Snappy

3. Use it

using EasyCompressor;

//Inject (ICompressor compressor)

var compressedBytes = compressor.Compress(inputBytes);

var uncompressedBytes = compressor.Decompress(compressedBytes);


Tips and Results

Origial data size is :

  • 89,535 bytes (about ≈ 90 KB) (binary serialized output of a json file by messagepack).

Compressed data size (for examle) :

  • 776 bytes for Zstd (115x compression ratio) that results in 99.13% memory and bandwidth saving.
  • 1,234 bytes for LZ4 (72x compression ratio) that results in 98.62% memory and bandwidth saving.

Maximum Compression :

  • Brotli
  • Zstd
  • LZMA
  • LZ4

Fastest Speed :

  • Zstd
  • Snappy
  • LZ4

Most Efficient :

  • Zstd (windows only package)
  • LZ4 (cross-platform package)

Moderated :

  • GZip
  • Deflate

Compression Ratio : higher is better Benchmark


Create an issue if you find a BUG or have a Suggestion or Question. If you want to develop this project :

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Give a Star! ⭐️

If you find this repository useful, please give it a star. Thanks!


EasyCompressor is Copyright © 2020 Mohammd Javad Ebrahimi under the MIT License.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Sharp (279,380
Compression (1,247
Gzip (272
Compress (218
Brotli (150
Decompression (133
Related Projects