{{short description|Lossless compression algorithm}} {{redirect|.zst|the game console emulator also using this file extension|ZSNES}} {{lowercase title}} {{Use dmy dates|date=January 2021}} {{Infobox software | name = Zstandard | author = Yann Collet | developer = Yann Collet, Nick Terrell, Przemysław Skibiński<ref>{{cite web|title=Contributors to facebook/zstd |url=https://github.com/facebook/zstd/graphs/contributors |access-date=26 Jan 2021 |website=github.com}}</ref> | operating system = Cross-platform | genre = Data compression | programming language = C | license = BSD-3-Clause or GPL-2.0-or-later (dual-licensed) | logo = Zstandard logo.png | logo_size = 110px | released = {{Start date|2015|01|23|df=y}} | discontinued = | latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}} | latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}} | latest preview version = | platform = Portable | size = | repo = {{URL|https://github.com/facebook/zstd}} }}

'''Zstandard''' is a lossless data compression algorithm developed by Yann Collet at Facebook. '''Zstd''' is the corresponding reference implementation in C, released as open-source software on 31 August 2016.<ref>{{cite news |last=De Simone |first=Sergio |date=2 September 2016 |url=https://www.infoq.com/news/2016/09/facebook-zstandard-compression |title=Facebook Open-Sources New Compression Algorithm Outperforming Zlib |publisher=InfoQ |access-date=20 April 2019 |archive-date=7 October 2021 |archive-url=https://web.archive.org/web/20211007055903/https://www.infoq.com/news/2016/09/facebook-zstandard-compression |url-status=live }}</ref><ref>{{cite news |last=Williams |first=Chris |date=31 August 2016 |title=Life imitates satire: Facebook touts zlib killer just like Silicon Valley's Pied Piper |url=https://www.theregister.co.uk/2016/08/31/facebook_open_source_database/ |access-date=2016-09-06 |publisher=The Register |archive-date=3 September 2016 |archive-url=https://web.archive.org/web/20160903085435/http://www.theregister.co.uk/2016/08/31/facebook_open_source_database/ |url-status=live }}</ref>

The algorithm was published in 2018 as {{IETF RFC|8478}}, which also defines an associated media type "application/zstd", filename extension "zst", and HTTP content encoding "zstd".<ref name="RFC8478"> {{cite IETF|title=Zstandard Compression and the application/zstd Media Type|rfc=8478|last1=Collet|first1=Yann|editor1-last=Kucherawy|editor1-first=Murray S.|editor1-link=Murray Kucherawy|date=October 2018|access-date=7 October 2020|series=Internet Engineering Task Force Request for Comments}} </ref>

==Features== Zstandard was designed to give a compression ratio comparable to that of the DEFLATE algorithm (developed in 1991 and used in the original ZIP and gzip programs), but faster, especially for decompression. It is tunable with compression levels ranging from negative 7 (fastest)<ref>{{Cite web |title=Release Zstandard v1.3.4 - faster everything · facebook/zstd |url=https://github.com/facebook/zstd/releases/tag/v1.3.4 |access-date=2024-03-27 |website=GitHub |language=en |archive-date=11 September 2021 |archive-url=https://web.archive.org/web/20210911024159/https://github.com/facebook/zstd/releases/tag/v1.3.4 |url-status=live }}</ref> to 22 (slowest in compression speed, but best compression ratio).

Starting from version 1.3.2 (October 2017), zstd optionally implements very-long-range search and deduplication ({{code|--long}}, 128&nbsp;MiB window) similar to rzip or lrzip.<ref>{{cite web |date=28 October 2021 |title=Command Line Interface for Zstandard library |url=https://github.com/facebook/zstd/blob/23dd28d/programs/README.md |website=GitHub |publisher=Facebook |language=en}}</ref>

Compression speed can vary by a factor of 20 or more between the fastest and slowest levels, while decompression is uniformly fast, varying by less than 20% between the fastest and slowest levels.<ref name=openzfs>{{cite web |last=Jude |first=Allan |url=http://www.open-zfs.org/w/images/b/b3/03-OpenZFS_2017_-_ZStandard_in_ZFS.pdf |title=ZStandard in ZFS |date=2017 |access-date=20 April 2019 |website=open-zfs.org |archive-date=18 December 2019 |archive-url=https://web.archive.org/web/20191218102535/http://open-zfs.org/w/images/b/b3/03-OpenZFS_2017_-_ZStandard_in_ZFS.pdf |url-status=live }}</ref> The Zstandard command-line has an "adaptive" ({{code|--adapt}}) mode that varies compression level depending on I/O conditions, mainly how fast it can write the output.

Zstandard at its maximum compression level gives a compression ratio close to lzma, lzham, and ppmx.<ref>{{cite web |url=http://mattmahoney.net/dc/silesia.html |title=Silesia Open Source Compression Benchmark |last=Mahoney |first=Matt |access-date=10 May 2019 |archive-date=21 January 2022 |archive-url=https://web.archive.org/web/20220121165038/http://mattmahoney.net/dc/silesia.html |url-status=live }}</ref><ref>{{cite web |url=http://mattmahoney.net/dc/text.html |title=Large Text Compression Benchmark, .2157 zstd |last=Mahoney |first=Matt |date=29 August 2016 |access-date=10 May 2019 |archive-date=31 March 2022 |archive-url=https://web.archive.org/web/20220331031650/http://mattmahoney.net/dc/text.html |url-status=live }}</ref> As of 2019, Zstandard reaches the Pareto frontier for decompression, as it produces output faster than any other open source algorithm with a similar or better compression ratio.<ref name="web-compression">{{citation |title=TurboBench: Static/Dynamic web content compression benchmark |url=https://sites.google.com/site/powturbo/home/web-compression |publisher=PowTurbo |access-date=6 January 2026 |archive-date=17 March 2022 |archive-url=https://web.archive.org/web/20220317204149/https://sites.google.com/site/powturbo/home/web-compression |url-status=live }}</ref>

Dictionaries can have a large impact on the compression ratio of small files, so Zstandard can use a user-provided compression dictionary. It also offers a training mode, able to generate a dictionary from a set of samples.<ref>{{Cite web |last1=Bockelman |first1=Brian |last2=Pivraski |first2=Jim |last3=Shadura |first3=Oksana |last4=Zhang |first4=Zhe |date=11 October 2017 |title=DIANA Contributions Update |quote=Facebook developers report massive speedups and compression ratio improvements when using dictionaries |url=https://indico.fnal.gov/event/15154/contribution/5/material/slides/0.pdf |access-date=27 March 2024 |website=Fermilab |archive-date=25 January 2018 |archive-url=https://web.archive.org/web/20180125015337/https://indico.fnal.gov/event/15154/contribution/5/material/slides/0.pdf |url-status=live }}</ref><ref>{{cite web |last1=Collet |first1=Yann |last2=Turner |first2=Chip |url=https://code.facebook.com/posts/1658392934479273/smaller-and-faster-data-compression-with-zstandard/ |title=Smaller and faster data compression with Zstandard |date=31 August 2016 |publisher=Facebook |access-date=3 September 2016 |archive-date=27 September 2016 |archive-url=https://web.archive.org/web/20160927080023/https://code.facebook.com/posts/1658392934479273/smaller-and-faster-data-compression-with-zstandard |url-status=live }}</ref> In particular, one dictionary can be loaded to process large sets of files with redundancy between files, but not necessarily within each file, such as for log files.

==Design==

Zstandard combines a dictionary-matching stage (LZ77) with a large search window and a fast entropy-coding stage. It uses Huffman coding alongside finite-state entropy (FSE), a variant of tANS.<ref>{{cite web|url=https://github.com/facebook/zstd/blob/23dd28d/doc/zstd_compression_format.md#entropy-encoding|title=Zstandard Compression Format|website=GitHub|publisher=Facebook|date=28 October 2021}}</ref>

==Usage==

{{Infobox file format | name = Zstandard | extension = <code>.zst</code><ref name="RFC8878"> {{cite IETF |title=Zstandard Compression and the application/zstd Media Type |rfc=8878 |last1=Collet |first1=Yann |editor1-last=Kucherawy |editor1-first=Murray S. |editor1-link=Murray Kucherawy |date=February 2021 |access-date=26 February 2023 |series=Internet Engineering Task Force Request for Comments}} </ref> | mime = <code>application/zstd</code><ref name="RFC8878"/> | genre = Data compression | magic = <code>28 B5 2F FD</code><ref name="RFC8878"/> | standard = {{IETF RFC|8878}} | url = {{URL|https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md}} }}

{{Infobox file format | name = Zstandard Dictionary | magic = <code>37 A4 30 EC</code><ref name="RFC8878"/> | standard = {{IETF RFC|8878}} | url = {{URL|https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#dictionary-format}} }} [[File:Example of zram on Linux screenshot.webp|thumb|Zstandard being used as compression method for zram]] The Linux kernel has included Zstandard since November 2017 (version 4.14) as a compression method for the btrfs and squashfs filesystems,<ref>{{cite web |last=Corbet |first=Jonathan |date=17 September 2017 |title=The rest of the 4.14 merge window [LWN.net] |url=https://lwn.net/Articles/733846/ |access-date=27 March 2024 |website=lwn.net |archive-date=22 November 2021 |archive-url=https://web.archive.org/web/20211122141753/https://lwn.net/Articles/733846/ |url-status=live }}</ref><ref>{{cite web |date=30 December 2017 |title=Linux_4.14 |url=https://kernelnewbies.org/Linux_4.14 |access-date=16 August 2018 |website=Kernelnewbies.org |archive-date=10 January 2018 |archive-url=https://web.archive.org/web/20180110114105/https://kernelnewbies.org/Linux_4.14 |url-status=live }}</ref><ref>{{cite web |last=Larabel |first=Michael |date=8 September 2017 |title=Zstd Compression For Btrfs & Squashfs Set For Linux 4.14, Already Used Within Facebook |url=https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.14-Zstd-Pull |website=www.phoronix.com |access-date=13 November 2017 |archive-date=25 July 2019 |archive-url=https://web.archive.org/web/20190725122757/https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.14-Zstd-Pull |url-status=live }}</ref> as well as for loadable kernel modules.

In 2017, Allan Jude integrated Zstandard into the FreeBSD kernel,<ref>{{cite web | url=https://github.com/freebsd/freebsd/commit/28ef16535cde21eeeaf75f6006b3a77952b3b51 | title=Integrate ZSTD into the kernel · freebsd/Freebsd-SRC@28ef165 | website=GitHub |publisher=The FreeBSD Project }}</ref> and it was subsequently integrated as a compressor option for core dumps (both user programs and kernel panics). It was also used to create a proof-of-concept OpenZFS compression method<ref name=openzfs /> which was integrated in 2020.<ref>{{cite web|url=https://github.com/openzfs/zfs/commit/10b3c7f5e424f54b3ba82dbf1600d866e64ec0a0|title=Add ZSTD support to ZFS · openzfs/ZFS@10b3c7f|website=GitHub|publisher=OpenZFS|access-date=12 October 2020|archive-date=10 September 2020|archive-url=https://web.archive.org/web/20200910151903/https://github.com/openzfs/zfs/commit/10b3c7f5e424f54b3ba82dbf1600d866e64ec0a0|url-status=live}}</ref>

The AWS Redshift and RocksDB databases include support for field compression using Zstandard.<ref name=Redshift>{{cite web |url=https://docs.aws.amazon.com/redshift/latest/dg/zstd-encoding.html |title=Zstandard Encoding - Amazon Redshift |date=20 April 2019 |publisher=Amazon Web Services |access-date=24 January 2018 |archive-date=14 August 2021 |archive-url=https://web.archive.org/web/20210814225631/https://docs.aws.amazon.com/redshift/latest/dg/zstd-encoding.html |url-status=dead }}<!-- root? hadoop? MyRocks ? SQL servers? --></ref>

In March 2018, Canonical tested<ref name="ubuntudeb">{{cite web |url=https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-Zstd-Deb-Packages |title=Canonical Working On Zstd-Compressed Debian Packages For Ubuntu |last=Larabel |first=Michael |date=12 March 2018 |website=phoronix.com |publisher=Phoronix Media |access-date=29 October 2019 |quote=The developers at Canonical are considering a feature freeze exception to get this newly-developed Zstd Apt/Dpkg support in Ubuntu 18.04 LTS. In doing so, they mention they would be looking at enabling Zstd compression for packages by default in Ubuntu 18.10. |archive-date=16 August 2021 |archive-url=https://web.archive.org/web/20210816101454/https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-Zstd-Deb-Packages |url-status=live }}</ref> the use of zstd as a deb package compression method by default for the Ubuntu Linux distribution. Compared with xz compression of deb packages, zstd at level 19 decompresses significantly faster, but at the cost of 6% larger package files. Support was added to Debian (and subsequently, Ubuntu) in April 2018 (in version 1.6~rc1).<ref>{{cite web |last=Nestor |first=Marius |title=New Ubuntu Installs Could Be Speed Up by 10% with the Zstd Compression Algorithm |url=https://news.softpedia.com/news/new-ubuntu-installs-could-be-speed-up-by-10-with-the-zstd-compression-algorithm-520177.shtml |website=Softpedia |access-date=13 August 2018 |date=12 March 2018 |archive-date=6 October 2021 |archive-url=https://web.archive.org/web/20211006045638/https://news.softpedia.com/news/new-ubuntu-installs-could-be-speed-up-by-10-with-the-zstd-compression-algorithm-520177.shtml |url-status=live }}</ref><ref name="ubuntudeb"/><ref> {{cite web |title=Debian Changelog for apt |url=https://metadata.ftp-master.debian.org/changelogs//main/a/apt/apt_1.8.2.3_changelog |website=Debian |access-date=7 November 2022 |language=en |date=19 April 2021 }}</ref>

Fedora added ZStandard support to RPM in May 2018 (Fedora release 28) and used it for packaging the release in October 2019 (Fedora&nbsp;31).<ref>{{cite web |title=Changes/Switch RPMS to ZSTD compression |url=https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression |website=Fedora Project Wiki |access-date=8 July 2020 |archive-date=2 June 2019 |archive-url=https://web.archive.org/web/20190602192906/https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression |url-status=live }}</ref> In Fedora&nbsp;33, the filesystem is compressed by default with zstd.<ref>{{cite web |last=Thurman |first=Andrew |date=14 April 2021 |title=Fedora Workstation 34 feature focus: Btrfs transparent compression |url=https://fedoramagazine.org/fedora-workstation-34-feature-focus-btrfs-transparent-compression/ |access-date=12 May 2022 |website=Fedora Magazine |language=en-US}}</ref><ref>{{cite web |title=Changes/BtrfsTransparentCompression |url=https://fedoraproject.org/wiki/Changes/BtrfsTransparentCompression |access-date=2022-05-12 |website=Fedora Project Wiki}}</ref>

Arch Linux added support for zstd as a package compression method in October 2019 with the release of the pacman&nbsp;5.2 package manager<ref>{{cite web |last=Larabel |first=Michael |date=16 October 2019 |title=Arch Linux Nears Roll-Out of ZSTD Compressed Packages for Faster Pacman Installs |url=https://www.phoronix.com/scan.php?page=news_item&px=Arch-Linux-Pacman-Zstd-Near |website=Phoronix |access-date=21 October 2019 |archive-date=18 March 2022 |archive-url=https://web.archive.org/web/20220318032712/https://www.phoronix.com/scan.php?page=news_item&px=Arch-Linux-Pacman-Zstd-Near |url-status=live }}</ref> and in January 2020 switched from xz to zstd for the packages in the official repository. Arch uses <code>zstd -c -T0 --ultra -20 -</code>; while the size of all compressed packages combined increased by 0.8% (compared to xz), the decompression speed is 14<!-- 1300% --> times faster, decompression memory increased by 50&nbsp;MiB when using multiple threads, and compression memory increased but scales with the number of threads used.<ref>{{cite web |url=https://www.archlinux.org/news/now-using-zstandard-instead-of-xz-for-package-compression/ |title=Now using Zstandard instead of xz for package compression |last=Broda |first=Mara |date=4 January 2020 |website=Arch Linux |access-date=5 January 2020 |archive-date=18 March 2022 |archive-url=https://web.archive.org/web/20220318032814/https://archlinux.org/news/now-using-zstandard-instead-of-xz-for-package-compression/ |url-status=live }}</ref><ref>{{cite mailing list |url=https://lists.archlinux.org/pipermail/arch-dev-public/2019-March/029542.html |mailing-list=arch-dev-public |title=RFC: (devtools) Changing default compression method to zstd |first=Mara |last=Broda |date=2019-03-25 |access-date=5 January 2020 |archive-date=17 August 2021 |archive-url=https://web.archive.org/web/20210817122817/https://lists.archlinux.org/pipermail/arch-dev-public/2019-March/029542.html |url-status=live }}</ref><ref> {{cite web |last1=Broda |first1=Mara |last2=Polyak |first2=Levente |date=27 December 2019 |title=makepkg.conf: change default compression method to zstd |website=GitHub |url=https://github.com/archlinux/devtools/commit/bcda211dd86b3bf54a9bc40d2e19f1aad4bbfbb8}} </ref> Arch Linux later also switched to zstd as the default compression algorithm for mkinitcpio initial ramdisk generator.<ref>{{cite web|last=Razzolini|first=Giancarlo|date=19 February 2021|title=News: Moving to Zstandard images by default on mkinitcpio|url=https://archlinux.org/news/moving-to-zstandard-images-by-default-on-mkinitcpio/|access-date=2021-12-28|website=Arch Linux}}</ref>

On 15 June 2020, Zstandard was implemented in version 6.3.8 of the zip file format with codec number&nbsp;93, deprecating the previous codec number of&nbsp;20 as it was implemented in version 6.3.7, released on 1 June.<ref name="zip638">{{citation |url=http://www.pkware.com/documents/APPNOTE/APPNOTE-6.3.8.TXT |title=APPNOTE.TXT - .ZIP File Format Specification Version: 6.3.8 |date=15 June 2020 |publisher=PKWARE |access-date=7 July 2020 }}</ref><ref name="zip637">{{citation |url=http://www.pkware.com/documents/APPNOTE/APPNOTE-6.3.7.TXT |title=APPNOTE.TXT - .ZIP File Format Specification Version: 6.3.7 |date=1 June 2020 |publisher=PKWARE |access-date=6 June 2020 }}</ref>

On 31 October 2023 Official Zstd support for compression/decompression was added to Windows Explorer in Windows 11 (via update package KB5031455)

In March 2024, Google Chrome version 123 (and Chromium-based browsers such as Brave or Microsoft Edge) added zstd support in the HTTP header <code>Content-Encoding</code>.<ref>{{Cite web |last=Jara |first=Adriana |date=19 March 2024 |orig-date= |title=New in Chrome 123 {{!}} Chrome Blog |url=https://developer.chrome.com/blog/new-in-chrome-123 |access-date=16 April 2024 |website=Chrome for Developers |publisher=Google |language=en}}</ref> In May 2024, Firefox release 126.0 added zstd support in the HTTP header <code>Content-Encoding</code>.<ref>{{cite web |title=Firefox 126.0, See All New Features, Updates and Fixes |url=https://www.mozilla.org/en-US/firefox/126.0/releasenotes/ |date=May 2024 |access-date=15 May 2024 |archive-date=13 May 2024 |archive-url=https://web.archive.org/web/20240513202356/https://www.mozilla.org/en-US/firefox/126.0/releasenotes/ |url-status=live }}</ref>

==License== The reference implementation is licensed under the BSD license, published at GitHub.<ref>{{cite news|last=Dignan |first=Larry |url=https://www.zdnet.com/article/facebook-open-sources-zstandard-data-compression-algorithm-aims-to-replace-technology-behind-zip/|title=Facebook open sources Zstandard data compression algorithm, aims to replace technology behind Zip|date=31 August 2016|publisher=ZDnet|access-date=1 September 2016}}</ref> Since version 1.0, published 31 August 2016,<ref>{{Cite web |title=Zstandard v1.0 |url=https://github.com/facebook/zstd/releases/tag/v1.0.0 |access-date=2025-01-23 |date=2016-08-31 |website=GitHub |publisher=Facebook |archive-date=7 April 2023 |archive-url=https://web.archive.org/web/20230407231122/https://github.com/facebook/zstd/releases/tag/v1.0.0 |url-status=live }}</ref> it had an additional Grant of Patent Rights.<ref>{{Cite web |title=v1.3.0/PATENTS · facebook/zstd |url=https://github.com/facebook/zstd/blob/v1.3.0/PATENTS |access-date=27 March 2024 |date=30 August 2016 |website=GitHub |publisher=Facebook |language=en |archive-date=15 May 2021 |archive-url=https://web.archive.org/web/20210515045048/https://github.com/facebook/zstd/blob/v1.3.0/PATENTS |url-status=live }}</ref>

From version 1.3.1, released 20 August 2017,<ref>{{Cite web |title=Release Zstandard v1.3.1 · facebook/zstd |url=https://github.com/facebook/zstd/releases/tag/v1.3.1 |access-date=27 March 2024 |date=20 August 2017 |website=GitHub |publisher=Facebook |language=en |archive-date=12 September 2020 |archive-url=https://web.archive.org/web/20200912235153/https://github.com/facebook/zstd/releases/tag/v1.3.1 |url-status=live }}</ref> this patent grant was dropped and the license was changed to a BSD + GPLv2 dual license.<ref>{{Cite web |title=New license by Cyan4973 · Pull Request #801 · facebook/zstd |url=https://github.com/facebook/zstd/pull/801 |access-date=27 March 2024 |date=19 August 2017 |website=GitHub |publisher=Facebook |language=en |archive-date=12 September 2020 |archive-url=https://web.archive.org/web/20200912201251/https://github.com/facebook/zstd/pull/801 |url-status=live }}</ref>

==See also== * LZ4 (compression algorithm) – a fast member of the LZ77 family * LZFSE – a similar algorithm by Apple used since iOS 9 and OS X 10.11 and made open source on 1 June 2016 * Zlib * Brotli – also integrated into browsers * Gzip – one of the most widely used compression tools

==References== {{Reflist|colwidth=30em}}

==External links== * {{Official website}} * {{Github|facebook/zstd}} * {{GitHub|mcmilk/7-Zip-zstd|7zip with Zstandard}} * "[https://engineering.fb.com/2016/08/31/core-infra/smaller-and-faster-data-compression-with-zstandard/ Smaller and faster data compression with Zstandard]", Yann Collet and Chip Turner, 31 August 2016, Facebook Announcement * [https://www.theguardian.com/info/developer-blog/2016/dec/01/discover-new-compression-iinovations-brotli-and-zstandard The Guardian is using ZStandard instead of zlib]

{{Compression methods}}{{Archive formats}}

Category:2016 software Category:C (programming language) libraries Category:Free data compression software Category:Lossless compression algorithms Category:Software using the BSD license Category:Data compression