How are data stored in a .gz format?

Gz format was created as an open source alternative to other compression formats, first released in 1992 with the zlib library as its reference implementation. Owing to its permissive licence, it has become one of the most widespread compression algorithms over the years, used for example as part of the HTTP protocol or in the .png file format. It is faster and easier to use than formats like 7zip, bz2 or xz, but its compression ratio is worse. Newer compression formats like zstd have both better compression ratio and better performance than .gz, but they are not used in common protocols.