From Wikipedia, the free encyclopedia
Jump to: navigation, search

Zopfli is a data compression algorithm that encodes data into the widely deployed DEFLATE format (known from the zip file format and zlib).[1][2] Zopfli is regarded as the most size-efficient Deflate encoder available.[3] A reference implementation is released as a free software programming library. The name is the Swiss German diminutive of “Zopf”, a special type of Hefezopf.[4]

Properties and use case[edit]

Zopfli can output either raw Deflate data stream or encapsulated into gzip or zlib formats. It can be configured to do more or less iterations than the default 15 to trade in processing time for compression efficiency.

Using the default setting, it achieves typically about 5 % better compression than zlib but takes around 80 times longer.[5] Decompression speed is practically unaffected.

Therefore, it is much less suited for on-the-fly compression and pays off if data gets compressed once and served a sufficiently large number of times.[6] This is typically true for static web content that is served with usually Deflate-based HTTP compression or has a Deflate-based file format like PNG or WOFF font files. (Most web clients support only Deflate or gzip, and not more advanced formats like Brotli or xz.) Another field are software updates or downloads with software package files that have a zip-based format like Android application packages (APK) or Java Archives (JAR), especially over mobile connections.


The higher data density is achieved by using more exhaustive compression techniques. The method is based on iterating entropy modeling and a shortest path search algorithm to find a low bit cost path through the graph of all possible Deflate representations.[7]


There is a reference implementation from the authors in the form of a programming library written in C. It is available as free software under the terms of version 2.0 of the permissive Apache License.

A first implementation in PHP can be found in php_zopfli. Because of the gzip/zlib-compatible data compression this library can also be used for compressing data before delivering it to the client like you would do with gzencode().

An implementation of Zopfli in C# can be found as part of the CompressSharper library ZopfliDeflater.cs


Zopfli is based on an algorithm from Jyrki Alakuijala. Zopfli was developed and implemented into a programming library by Google Inc. employees Jyrki Alakuijala and Lode Vandevenne as a sideproject in their “20 percent time”. It was first released to the public in March 2013. An official version 1.0.0 was released on April 25, 2013. The advent of Zopfli displaced Ken Silverman's KZIP as the most size-efficient DEFLATE implementation and 7-Zip's deflater as the most size-efficient freely licensed one. After several adaptations of Zopfli for PNG appeared on GitHub, the latest Git version of Zopfli has contained the PNG optimizer ZopfliPNG since May 2013.[8]

PNG optimization[edit]

The Zopfli algorithm can be used to compress Portable Network Graphics (PNG) files because PNG uses a DEFLATE compression layer. There is a PNG optimization tool named ZopfliPNG from the authors of Zopfli. The Zopfli algorithm has also been integrated into other PNG compression optimization tools like advpng from the AdvanceCOMP utility suite.[9]

Silverman's KZIP-based PNG encoder PNGOUT used to be the single most size-efficient PNG encoder available. It was displaced by Zopfli-based PNG encoders and optimization tools.

External links[edit]