Skip to content
A Zstandard wrapper for .Net
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Zstandard.Net.Benchmark version 1.1.7 Mar 16, 2019
Zstandard.Net.Sandbox Use shared ArrayPool for internal buffer Feb 17, 2018
Zstandard.Net version 1.1.7 Mar 16, 2019
.gitignore Initial commit Nov 6, 2017
LICENSE Update LICENSE Nov 6, 2017 Update Nov 12, 2017
Zstandard.Net.sln Added pool for internal buffer to reduce garbage collections Feb 17, 2018

A Zstandard wrapper for .Net

Zstandard is a real-time compression algorithm, providing high compression ratios. It offers a very wide range of compression / speed trade-off, while being backed by a very fast decoder. It also offers a special mode for small data, called dictionary compression, and can create dictionaries from any sample set. Zstandard library is provided as open source software using a BSD license.


byte[] input = GetTestData();
byte[] compressed = null;
byte[] output = null;

// load a dictionary that is trained for the data (optional).
var dictionary = new ZstandardDictionary("loremipsum.zdict");

// compress
using (var memoryStream = new MemoryStream())
using (var compressionStream = new ZstandardStream(memoryStream, CompressionMode.Compress))
	compressionStream.CompressionLevel = 11;               // optional!!
	compressionStream.CompressionDictionary = dictionary;  // optional!!
	compressionStream.Write(input, 0, input.Length);
	compressed = memoryStream.ToArray();

// decompress
using (var memoryStream = new MemoryStream(compressed))
using (var compressionStream = new ZstandardStream(memoryStream, CompressionMode.Decompress))
using (var temp = new MemoryStream())
	compressionStream.CompressionDictionary = dictionary;  // optional!!
	output = temp.ToArray();

// test output
if (output.SequenceEqual(input) == false)
	throw new Exception("Output is different from input!");


Download the library from NuGet:

You can’t perform that action at this time.