ZIP


 * Not to be confused with Zip disk, an unrelated disk cartridge unit.

ZIP is one of the most popular file compression formats. It was created in 1989 as the native format of the PKZIP program, which was introduced by Phil Katz (with co-creator Gary Conway) in the wake of a lawsuit (which he lost) against him by the makers of the then-popular ARC program (and file format) for copyright and trademark infringement in an earlier program PKARC which had been file-compatible with ARC. This resulted in Katz creating a new file format, which rapidly overtook ARC in popularity (to a large extent because of BBS sysops, then the primary users of such compression, resenting the lawsuit). Many programs have been released for a variety of operating systems to compress and decompress ZIP files, and native support for the format is built into several popular operating systems.

ZIP implementations vary in their support for features in the specification from PKWARE, particularly features added since version 2 (1993), some of which are protected by patents and require licensing. Many implementations limit the use of compression to the DEFLATE algorithm, introduced with version 2. Extensions incorporated into the specification that have been widely adopted are: long filenames; large files (using a technique known as ZIP64); and filenames in UTF-8. In 2011 work began on an interoperable subset of the latest APPNOTE.TXT with the intention of publication as ISO/IEC 21320-1, Document Container File -- Part 1: Core. As of November 2012, a discussion draft is available. Designed to promote interoperable implementations, the draft ISO/IEC 21320-1 prohibits compression other than using DEFLATE, segmentation or multiple volumes, and features that are subject to patents.

While .zip is the usual file extension, ZIP-formatted files can be found with many other extensions since a number of other file formats use ZIP compression but store their files in application-specific extensions. See Category:ZIP based file formats for a list of such formats.

Disambiguation
The term "ZIP compression" is sometimes misleadingly used to mean DEFLATE (which is by far the most common compression scheme used in ZIP files). In such cases, the compressed data format could turn out to be raw DEFLATE, or zlib, or gzip.

Identification
The byte sequence  (the "end of central directory signature") appears somewhere in the file, usually beginning exactly 22 bytes from the end of the file. However, it will appear earlier if the file contains a "ZIP file comment" (common in the BBS era, but rare today), or for various other reasons. There seems to be no theoretical limit to how far back you may have to search for the signature, but some software limits it to around 64KB, which is the maximum length of a comment.

Most ZIP files (but not self-extracting ZIP files) happen to begin with. This is not a global file signature, but is the signature that appears once for every compressed file inside the ZIP file. Some ZIP-based formats are designed such that they necessarily begin in this way. But in general, it is even legal for a ZIP file to contain zero files, and such a ZIP file would not contain this signature at all.

That Phil Katz guy has thus managed to get his initials at the start of a large number of files on many millions of computers and devices, given how many file formats are based on ZIP (even if they use different extensions). He died in 2000, but this memorial to him will live on indefinitely.

Compression
Each file in a ZIP file is compressed using one of a number of compression algorithms. Only compression types 0 (uncompressed) and 8 (DEFLATE) are likely to be seen in modern portable ZIP files. In old ZIP files, types 1 (Shrink) and 6 (Implode) are common.

Extensible data fields
Each member file of a ZIP file may have one or more extensible data fields (or extra fields), containing arbitrary data. Each field is tagged with a 16-bit identifier. Extra fields are normally used for platform-specific or filesystem-specific metadata, or to work around limitations of the original ZIP format. They are not normally used for application-specific data.

Most of the extra fields in use are documented in the ZIP "APPNOTE" specification, or by the Info-ZIP software (e.g. the proginfo/extrafld.txt file in the Zip program's source distribution).

Specifications

 * APPNOTEs - The format documentation from PKWARE is traditionally in a file named APPNOTE.TXT.
 * APPNOTE from PKWARE (latest version of formal spec)
 * APPNOTE Archives from PKWARE (selected versions all the way back to 1.0)
 * Documentation from Info-ZIP (Includes Info-ZIP variants on APPNOTE.TXT dated from 1996 to 2004, specifications used as the basis for various open-source tools)
 * LoC archive
 * An early version of APPNOTE (apparently from PKZIP v1.10)
 * - Possibly the first v2.x APPNOTE
 * APPNOTE v6.1.0, from archive.org
 * Bundled with PKZIP software through v1.93 - refer to the section below.
 * IANA registration for application/zip in July 1993 (corresponds to version 2 of APPNOTE.TXT)
 * November 2012 working draft of ISO/IEC WD 21320-1, Document Container File -- Part 1: Core Intended as restricted subset of APPNOTE 6.3.3 designed to promote interoperability.
 * February 2013 committee draft of ISO/IEC CD 21320-1, Document Container File -- Part 1: Core Essentially the same as November 2012 working draft except that it mandates use of the UTF-8 indicator.
 * Archive format info, including ZIP (from 1989, when ZIP was newly released)
 * ZIP file header format (among other archive types)
 * TorrentZip
 * Note that in general there is no official file name encoding for ZIP files, and non ASCII filenames are not generally well supported. The original implementation specified IBM Code Page 437 for filenames, but as many characters cannot be expressed in that encoding, the filename bytes have often been interpreted using the current system codepage (implementation dependent behaviour). There is a flag to specify UTF-8 as the encoding, but it is not supported in all major clients (e.g. Windows Explorer).
 * Info-ZIP's "extra fields" documentation

Software

 * Info-ZIP: Zip, UnZip
 * 7-Zip
 * zlib - The zlib library does not support ZIP format, but it is distributed with "minizip" code that supports most ZIP files.
 * libzip - Uses zlib.
 * libarchive - Uses zlib.
 * zziplib
 * Archive::ZZip: Perl bindings for zziplib
 * miniz
 * PKZIP
 * For DOS (main line): ·  ·  ·  ·  · ' ·  ·  ·  · ' ·
 * For Windows console: [ 2.50] · [ 4.00]
 * Various versions at old-dos.ru
 * (no encryption)
 * Konvertor
 * (for analysis, or converting old compression methods)
 * [ PCDEZIP] - Source code and DOS binary to decompress Deflate and all older methods (1993)

Sample files

 * https://github.com/corkami/pocs/tree/master/zip
 * Examples that use the uncommon "Reduce" compression scheme:, → D1-MAC.ZIP
 * https://telparia.com/fileFormatSamples/archive/zip/

Links

 * Wikipedia: ZIP (file format)
 * Wikipedia: PKZIP
 * Zip files all the way down (creating an infinitely-regressed ZIP file)
 * ZIP101 an archive walkthrough
 * Serve deepzoom images from a zip archive with openseadragon
 * How are zlib, gzip and Zip related? What do they have in common and how are they different? - Response to StackOverflow question by zlib/gzip co-creator Mark Adler
 * Does Microsoft OneDrive export large ZIP files that are corrupt? - Discusses an issue where large ZIP files generated by Microsoft OneDrive result in read errors when they are opened with tools like Info-Zip and 7-Zip
 * ZIP is Broken, Except it’s Not, Except it Is
 * Zip Files: History, Explanation and Implementation and The Legacy Zip Compression Methods
 * Zip - How not to design a file format.
 * Ten thousand security pitfalls: The ZIP file format by Gynvael Coldwind (2018)