gzip is a
file format
A file format is a Computer standard, standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary format, pr ...
and a
software application
Application software is any computer program that is intended for end-user use not computer operator, operating, system administration, administering or computer programming, programming the computer. An application (app, application program, sof ...
used for
file compression and decompression. The program was created by
Jean-loup Gailly and
Mark Adler as a
free software
Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
replacement for the
compress program used in early
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
systems, and intended for use by
GNU (from which the "g" of gzip is derived). Version 0.1 was first publicly released on 31 October 1992, and version 1.0 followed in February 1993.
The decompression of the ''gzip'' format can be implemented as a
streaming algorithm
In computer science, streaming algorithms are algorithms for processing data streams in which the input is presented as a sequence of items and can be examined in only a few passes, typically one-pass algorithm, just one. These algorithms are desi ...
, an important feature for
Web protocols,
data interchange and
ETL (in
standard pipes) applications.
File format
gzip is based on the
DEFLATE algorithm, which is a combination of
LZ77
LZ77 and LZ78 are the two lossless data compression algorithms published in papers by Abraham Lempel and Jacob Ziv in 1977 and 1978.
They are also known as Lempel-Ziv 1 (LZ1) and Lempel-Ziv 2 (LZ2) respectively. These two algorithms form the basis ...
and
Huffman coding
In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding or using such a code is Huffman coding, an algorithm developed by ...
. DEFLATE was intended as a replacement for
LZW and other
patent
A patent is a type of intellectual property that gives its owner the legal right to exclude others from making, using, or selling an invention for a limited period of time in exchange for publishing an sufficiency of disclosure, enabling discl ...
-encumbered
data compression
In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compressi ...
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
s which, at the time, limited the usability of the
compress utility and other popular archivers.
"gzip" also refers to the gzip file format (described in the table below). In short, it contains a 10-byte header, optional extra headers, a deflate-compressed
payload and an 8-byte trailer.

Although its file format also allows for multiple such streams to be
concatenated (gzipped files are simply decompressed concatenated as if they were originally one file), gzip is normally used to compress just single files. Compressed archives are typically created by assembling collections of files into a single
tar archive (also called
tarball), and then compressing that archive with gzip. The final compressed file usually has the extension or .
gzip is not to be confused with the
ZIP archive format, which also uses
DEFLATE. The ZIP format can hold collections of files without an external archiver, but is less compact than compressed
tarballs holding the same data, because it compresses files individually and cannot take advantage of redundancy between files (
solid compression).
The gzip file format is also not to be confused with that of the compress utility, based on LZW, with extension ; however, the gunzip utility is able to decompress .Z files.
Implementations
Various implementations of the program have been written. The most commonly known is the GNU Project's implementation using
Lempel-Ziv coding (LZ77).
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free software, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking NetBSD ...
's version of gzip is actually the
compress program, to which support for the gzip format was added in OpenBSD 3.4. The "g" in this specific version stands for ''
gratis''.
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
,
DragonFly BSD
DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD in ...
and
NetBSD
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
use a BSD-licensed implementation instead of the GNU version; it is actually a
command-line interface
A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
for
zlib
zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
intended to be compatible with the GNU implementations' options. These implementations originally come from
NetBSD
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
, and support decompression of
bzip2
bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
and the Unix
pack format.
An alternative compression program achieving 3-8% better compression is
Zopfli. It achieves gzip-compatible compression using more exhaustive algorithms, at the expense of compression time required. It does not affect decompression time.
pigz
, written by Mark Adler, is compatible with gzip and speeds up compression by using all available CPU cores and threads.
Damage recovery
Data in blocks prior to the first damaged part of the archive is usually fully readable. Data from blocks not demolished by damage that are located afterward ''may'' be
recoverable through difficult workarounds.
Derivatives and other uses
The
tar utility included in most Linux distributions can extract .tar.gz files by passing the option, e.g., , where
-z
instructs decompression,
-x
means extraction, and
-f
specifies the name of the compressed archive file to extract from. Optionally,
-v
(''verbose'') lists files as they are being extracted.
zlib
zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
is an abstraction of the DEFLATE algorithm in library form which includes support both for the gzip file format and a lightweight
data stream
In connection-oriented communication, a data stream is the transmission of a sequence of digitally encoded signals to convey information. Typically, the transmitted symbols are grouped into a series of packets.
Data streaming has become u ...
format in its API. The zlib stream format, DEFLATE, and the gzip file format were standardized respectively as RFC 1950, RFC 1951, and RFC 1952.
The gzip format is used in
HTTP compression, a technique used to speed up the sending of
HTML
Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
and other content on the
World Wide Web
The World Wide Web (WWW or simply the Web) is an information system that enables Content (media), content sharing over the Internet through user-friendly ways meant to appeal to users beyond Information technology, IT specialists and hobbyis ...
. It is one of the three standard formats for HTTP compression as specified in RFC 2616. This
RFC also specifies a zlib format (called "DEFLATE"), which is equal to the gzip format except that gzip adds eleven bytes of overhead in the form of headers and trailers. Still, the gzip format is sometimes recommended over zlib because
Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated as IE or MSIE) is a deprecation, retired series of graphical user interface, graphical web browsers developed by Microsoft that were u ...
does not implement the standard correctly and cannot handle the zlib format as specified in RFC 1950.
zlib DEFLATE is used internally by the
Portable Network Graphics
Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster graphics, raster-graphics file graphics file format, format that supports lossless data compression. PNG was developed as an improved, non-patented ...
(PNG) format.
Since the late 1990s,
bzip2
bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
, a file compression utility based on a block-sorting algorithm, has gained some popularity as a gzip replacement. It produces considerably smaller files (especially for source code and other structured text), but at the cost of memory and processing time (up to a factor of 4).
AdvanceCOMP,
Zopfli, libdeflate and
7-Zip
7-Zip is a free and open-source file archiver, a utility used to place groups of files within compressed containers known as "archives". It is developed by Igor Pavlov and was first released in 1999. 7-Zip has its own Archive file, archive forma ...
can produce gzip-compatible files, using an internal DEFLATE implementation with better compression ratios than gzip itself—at the cost of more processor time compared to the reference implementation.
Research published in 2023 showed that simple lossless compression techniques such as gzip could be combined with a
k-nearest-neighbor classifier to create an attractive alternative to
deep neural networks for text classification in
natural language processing
Natural language processing (NLP) is a subfield of computer science and especially artificial intelligence. It is primarily concerned with providing computers with the ability to process data encoded in natural language and is thus closely related ...
. This approach has been shown to equal and in some cases outperform conventional approaches such as
BERT due to low resource requirements, e.g. no requirement for
GPU hardware.
See also
*
Comparison of file archivers
*
Free file format
*
List of archive formats
This is a list of file formats used by file archiver, archivers and data compression, compressors used to create Archive file, archive files.
Archive formats by purpose
Archive formats are used for backups, mobility, and archiving. Many archive ...
*
List of Unix commands
This is a list of the shell commands of the most recent version of the Portable Operating System Interface (POSIX) IEEE Std 1003.1-2024 which is part of the Single UNIX Specification (SUS). These commands are implemented in many shells on moder ...
*
Libarc
*
Brotli
*
zlib
zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
Notes
References
RFC 1952 – GZIP file format specification version 4.3
External links
*
{{GNU
Archive formats
Cross-platform software
Free data compression software
Free software programmed in C
GNU Project software
IBM i Qshell commands
Inferno (operating system) commands
Lossless compression algorithms
Plan 9 commands
Unix archivers and compression-related utilities