Return
File Compressor

Options

Drag and drop files or folders here

Results

Add files, then press Compress or Compare All Methods. Sizes, ratios, entropy limits and transfer times appear here.

File Preview

No files added yet.
Select a file to preview it.

What Compression Does

Data compression represents the same information using fewer bits. It works because real data is rarely random: text repeats words and letter patterns, source code repeats keywords, logs repeat timestamps and message templates, and bitmaps repeat runs of similar pixels. A compressor finds these regularities and encodes them more compactly, while a decompressor reverses the process. [Wikipedia, Data Compression]

Three Kinds of Redundancy

Statistical redundancy means some symbols are far more common than others. In English text the letter "e" is much more frequent than "z", so giving "e" a shorter code saves space (Huffman and arithmetic coding exploit this). Repetition means the same sequence appears again and again, so later copies can be replaced by a short pointer to an earlier copy (LZ77-style matching). Structural redundancy means the data follows a format with predictable fields, which is why specialized codecs and context modeling can beat general tools on known formats. [Wikipedia, Lossless Compression] [Wikipedia, Run-Length Encoding]

Lossless vs Lossy

Lossless compression guarantees that decompression returns every original byte. It is mandatory for programs, documents, databases, and archives. ZIP, GZIP, ZLIB, bzip2, XZ, Brotli, Zstandard, and LZ4 are all lossless. Lossy compression permanently discards information that people are unlikely to notice, which is how JPEG, MP3, and video codecs reach very small sizes. Lossy output cannot be restored to the original, and this tool only performs lossless compression. [Wikipedia, Lossy Compression]

How Results Are Measured

  • Compression ratio = original size / compressed size. A ratio of 4:1 means the output is a quarter of the input.
  • Space saved = 1 - (compressed / original), shown as a percentage. A 4:1 ratio saves 75%.
  • Bits per byte = compressed bits / original bytes. Uncompressed data is 8 bits per byte.
  • Transfer time = bytes x 8 / (Mbps x 1,000,000) seconds. It ignores latency, protocol overhead, and congestion, so real transfers take somewhat longer.

Why Some Files Do Not Shrink

No lossless compressor can make every possible input smaller. There are 2^n different files of n bits but fewer than 2^n files that are strictly shorter, so if every file shrank, two different files would have to share one output and could not be told apart. This counting argument is a form of the pigeonhole principle. In practice, data that is already compressed or encrypted looks statistically random and stays about the same size, or grows by a few bytes of header overhead. [Wikipedia, Pigeonhole Principle] [Wikipedia, Limitations of Lossless Compression]

Speed, Memory, and Ratio

Every compressor trades three things: how small the output is, how fast it compresses and decompresses, and how much memory it needs. Higher levels usually search harder for repeated data, which costs more CPU time for a modest gain in ratio. Decompression is normally much faster than compression, which suits files that are written once and read many times, such as web assets and software downloads.

Shannon Entropy

In 1948 Claude Shannon defined the entropy of a source as H = -sum(p x log2 p), where p is the probability of each symbol. For bytes, H ranges from 0 bits (the same byte repeated forever) to 8 bits (all 256 values equally likely). Entropy is the average number of bits per symbol needed by an ideal coder that knows only the symbol probabilities. [Wikipedia, Information Entropy] [Wikipedia, A Mathematical Theory of Communication]

The Source Coding Theorem

Shannon's source coding theorem states that, for a source whose symbols are independent, no lossless code can average fewer bits per symbol than the entropy, and codes exist that come arbitrarily close to it. This tool uses the theorem to give an order-0 floor: file size x entropy / 8 bytes. It treats every byte as independent of its neighbors. [Wikipedia, Source Coding Theorem]

Why Real Compressors Can Beat the Floor

The order-0 floor only counts byte frequencies. Real data has structure across bytes: the letter "q" is almost always followed by "u", a word that appeared earlier is likely to appear again, and a log line often repeats the previous line with a new timestamp. Compressors that use repeated sequences or context can therefore go well below the order-0 floor. A file made of one 1 KB block repeated 1,000 times has the same order-0 entropy as one block, yet it compresses to almost nothing. The floor is a reference point, not an absolute limit.

Reading Entropy Values

  • Roughly 0 to 2 bits per byte: highly repetitive or sparse data, such as blank padding or simple bitmaps. Expect large savings.
  • Roughly 4 to 5.5 bits per byte: typical English text, source code, and markup. Order-0 alone suggests 30% to 50% savings, and repeated words typically push real compression further.
  • Close to 8 bits per byte: compressed, encrypted, or random data. Little or nothing can be saved.

Arithmetic and Range Coding

Because Huffman coding must spend a whole number of bits on each symbol, it can waste part of a bit per symbol. Arithmetic coding and range coding encode an entire message as a single number within a narrowing interval, so they can approach the entropy limit very closely. LZMA uses a range coder, and many high-ratio context-mixing compressors are built on arithmetic coding. [Wikipedia, Arithmetic Coding]

Kolmogorov Complexity

The true minimum size of a specific file is the length of the shortest program that outputs it, called its Kolmogorov complexity. It is provably not computable in general, so no tool can calculate the exact best possible compressed size. A string like the first million digits of pi looks random to a statistical compressor but is generated by a tiny program, which shows why entropy figures are only one view of compressibility. [Wikipedia, Kolmogorov Complexity]

How the Estimates for Other Algorithms Are Built

When you run Compare All Methods, the tool measures real TAR.GZ level 6 output and multiplies it by typical size ratios for three content classes: text, general binary, and already compressed files. For example, text tends to shrink roughly 10% to 20% further with Brotli or Zstandard at high settings and about 20% with XZ, while LZ4 measured here produces noticeably larger output than gzip. Because actual results depend heavily on the files, these rows are labelled estimates and should be treated as ballpark values only.

DEFLATE: The Engine Behind ZIP, GZIP, and ZLIB

DEFLATE combines two ideas. First, LZ77 scans the data using a sliding window of up to 32 KB and replaces repeated strings with a (distance, length) pair, where matches are 3 to 258 bytes long. Second, Huffman coding assigns shorter bit codes to the literals, lengths, and distances that occur most often. The compressed stream is split into blocks, each with its own Huffman tables. DEFLATE is the algorithm this tool uses for every format. [RFC 1951, DEFLATE Compressed Data Format] [Wikipedia, Deflate]

Huffman Coding

Huffman coding builds a binary tree from symbol frequencies so that frequent symbols get short codes and rare ones get long codes. No code is a prefix of another, so the bit stream can be decoded without separators. It produces the best possible code when every symbol must use a whole number of bits, which means it can land up to one bit per symbol above the entropy limit. [Wikipedia, Huffman Coding]

LZ77 Sliding Window

Lempel and Ziv's 1977 method keeps a window of recently seen data and, when the next bytes match something in that window, emits a reference instead of the bytes. A larger window finds more matches but needs more memory and search time. DEFLATE's window is only 32 KB, which is why two similar files placed far apart in an archive do not help each other when compressed with gzip. [Wikipedia, LZ77 and LZ78]

What the Level Slider Changes

Levels 1 to 9 change how hard the compressor searches for matches. Low levels accept the first reasonable match and run quickly. High levels check many more candidates and use lazy matching to look one step ahead for a better match, which is slower but produces smaller output. Level 6 is the default in zlib and gzip because gains beyond it are usually small compared with the extra time. Level 0 stores the data uncompressed, which is useful for bundling files that are already compressed. [zlib, Manual]

The Wrappers: ZIP, GZIP, ZLIB

All three formats carry DEFLATE data but add different headers and checksums. GZIP adds a 10-byte header and an 8-byte trailer holding a CRC-32 and the original length. ZLIB adds a 2-byte header and a 4-byte Adler-32 checksum. ZIP is a container for many files, with a local header per file, a central directory at the end, and an end record. The compressed data inside is the same, so size differences between them come mostly from this overhead. [RFC 1952, GZIP File Format] [RFC 1950, ZLIB Format]

bzip2

bzip2 applies the Burrows-Wheeler transform, which rearranges the data so similar contexts sit together, followed by move-to-front coding and Huffman coding. It usually compresses text better than gzip but is slower, and it has largely been replaced by XZ and Zstandard in new projects. [Wikipedia, bzip2]

LZMA and XZ

LZMA uses an LZ77-style matcher with very large dictionaries (megabytes up to gigabytes) and a range coder that models bits with adaptive probabilities. It gives some of the best general-purpose ratios and is used by 7z and the .xz format, but compression is slow and memory-hungry. Decompression is much faster than compression. [Wikipedia, LZMA] [XZ Utils, Project Page]

Brotli

Brotli, defined in RFC 7932, uses LZ77 matching, Huffman coding, second-order context modeling, and a built-in static dictionary of common words and phrases from web content. That dictionary makes it especially strong on small HTML, CSS, and JavaScript files. Its quality setting runs from 0 to 11, where the top levels are slow to compress but fast to decompress. [RFC 7932, Brotli Format] [Google, Brotli Repository]

Zstandard

Zstandard (zstd) pairs LZ77-style matching with fast entropy coders (finite state entropy and Huffman). It offers levels from fast negative levels up to 22, supports large windows and trained dictionaries for small files, and decompresses at very high speed at nearly every level. That wide range is why it is popular for package managers, databases, and file systems. [RFC 8878, Zstandard Format] [Zstandard, Project Page]

LZ4

LZ4 skips entropy coding entirely and works on byte-aligned matches, which makes it extremely fast, often several gigabytes per second per core, at the cost of a lower ratio. It suits cases where speed matters more than size, such as in-memory caches and real-time logging. [LZ4, Project Page]

Methods Implemented in This Page

Three extra methods are written directly in this page's script so you can see how very different ideas perform on your data. They report real measured sizes but use simple custom output, so no standard tool can open their files and they have no download button. RLE (PackBits) replaces runs of identical bytes with a count and a value; it shines on blank or flat data and can slightly expand ordinary text. Huffman (order-0) assigns optimal prefix codes from byte frequencies alone, with no repeat detection, so its size lands near the entropy floor plus a 260-byte header. LZ4 block is a working compressor for the LZ4 block format, with a 64 KB window and a single hash probe, so it is fast but compresses a little less than the reference LZ4 at its higher settings. [Wikipedia, PackBits] [LZ4, Block Format]

Rule of Thumb

  • Smallest output, time is irrelevant: XZ/LZMA or high-level Zstandard.
  • Web text delivered to browsers: Brotli, with gzip as the fallback.
  • Balanced speed and ratio: Zstandard at a middle level.
  • Maximum speed: LZ4.
  • Maximum compatibility: ZIP or gzip, which every platform can open.

ZIP Structure

A ZIP archive stores each file as its own entry: a local header (30 bytes plus the file name), the compressed data, and later a central directory record (46 bytes plus the file name) that lets programs list contents and jump to any entry. A final end-of-central-directory record of 22 bytes closes the archive. Because each file is compressed independently, you can extract one file without reading the rest, but similar files cannot share patterns. Many tiny files pay the per-entry overhead repeatedly, which can make ZIP larger than TAR.GZ for folders full of small files. [Wikipedia, ZIP File Format] [PKWARE, ZIP Application Note]

TAR and TAR.GZ

TAR only bundles files; it does not compress. Each file gets a 512-byte header and its data is padded up to a multiple of 512 bytes, and the archive ends with two blocks of zeros. Gzip then compresses the whole bundle as a single stream, which is called solid compression. Solid compression avoids per-file headers and lets similar files help each other, but only within DEFLATE's 32 KB window, so the gain is limited for big files. It also means extracting one file requires decompressing everything before it. Formats with larger windows, such as XZ and Zstandard in long-range mode, benefit far more from solid archives. [Wikipedia, Tar] [GNU, Tar Manual]

Separate GZIP, ZLIB, or Raw DEFLATE Files

The per-file options (GZIP, ZLIB, and raw DEFLATE, which has no header at all) compress every file on its own, with no folder structure and no shared patterns. They are mainly useful for preparing individual assets, for example a pre-compressed copy of each JavaScript or CSS file to serve with a web server. In this tool the individually compressed files are placed in a ZIP at level 0 so they download as one file without being compressed twice.

Already Compressed Container Formats

Several everyday formats are already compressed internally. DOCX, XLSX, PPTX, JAR, and APK files are ZIP archives. JPEG, PNG, WebP, AVIF, MP3, AAC, MP4, and WebM use their own compression. Compressing these again typically saves under 2% and can add a few bytes. To make them smaller, re-encode them with a more efficient codec or lower quality instead of zipping them.

Compression on the Web

Browsers announce the encodings they support in the Accept-Encoding request header, and servers answer with a Content-Encoding header naming the one they used, commonly gzip, br (Brotli), or zstd in recent browsers. Compressing text responses is one of the cheapest ways to speed up a site, since HTML, CSS, JavaScript, JSON, and SVG often shrink by 60% to 80%. Images and video should not be compressed again at this layer. Static files are best pre-compressed once at a high level, while dynamic responses use a faster setting so latency stays low. [MDN, Content-Encoding Header] [MDN, HTTP Compression]

Compression Inside the Browser

Modern browsers include a built-in CompressionStream API that supports gzip, deflate, and deflate-raw, but not Brotli, Zstandard, or XZ. For that reason this tool relies on the small open source library fflate for its ZIP and TAR.GZ output, and Brotli, Zstandard, and XZ appear only as estimates. RLE, Huffman, and LZ4 are implemented in this page instead. [MDN, CompressionStream] [fflate, GitHub Repository]

Layout

The left panel holds your options and actions. The top right shows results. The bottom right shows every added folder and file as a tree and shows an organized information sheet for the one you select: name, folder, size, type, entropy, order-0 floor, and a quick DEFLATE level 6 estimate.

Step by Step

  • Add data: drag files or several folders at once onto the drop area, or use Choose Files or Choose Folder as many times as you like. Each choice is added to the list, and the preview pane shows every folder with its files, which you can collapse or remove individually. Folder structure is preserved in ZIP, TAR, and TAR.GZ output.
  • Pick a format and level: ZIP is the most widely compatible. TAR.GZ often wins on many small related files. Level 6 is a balanced default.
  • Check your upload speed: it is measured automatically when the page loads and only drives the transfer time figures, so you can see how long the original and compressed data would take to send. Type a value to override it.
  • Compress: produces a downloadable archive and a per-file table with original size, compressed size, space saved, entropy, and the order-0 floor.
  • Compare All Methods: runs ZIP at levels 0, 1, 6, and 9 and TAR.GZ at levels 1, 6, and 9, marks the smallest, measures TAR with no compression plus the RLE, Huffman, and LZ4 methods, and adds estimated sizes for Brotli, Zstandard, and XZ.

Understanding the Results

Per-file sizes in the results table come from compressing each file alone with DEFLATE, so they show how compressible each file is on its own. The archive total can differ: ZIP is roughly the sum of these plus header overhead, while TAR.GZ can be smaller or larger depending on how much similar data sits within 32 KB of each other. If the entropy is near 8 bits per byte and the saved percentage is near zero, the file is already compressed and no setting will help.

Connection Speed Test

When the page loads it measures your connection in the background. First it reads the browser's own bandwidth estimate where available (Chromium-based browsers only), then it downloads about 8 MB and uploads about 2 MB of dummy data using Cloudflare's public speed test service. The result fills the Upload speed box, since the transfer times describe sending your data. It is a rough single-connection measurement, so it can differ from other speed tests, and it never involves your files. If the test is blocked or fails, the box keeps a default of 50 Mbps that you can edit. [Cloudflare, Speed Test] [MDN, NetworkInformation downlink]

Privacy and Limits

All compression happens locally in your browser tab. No file is uploaded to any server; the only network traffic is the dummy-data speed test described above. Because files are held in memory, very large selections (many hundreds of megabytes) may be slow or fail on devices with limited RAM. Folder selection requires a modern browser such as a current version of Chrome, Edge, Firefox, or Safari.

Tips for Better Results

  • Group similar files, such as many JSON or log files, into one TAR.GZ rather than separate files.
  • Do not bother compressing photos, videos, or music. Use level 0 if you only want to bundle them.
  • If you are preparing web files, use the per-file GZIP option at level 9 and serve Brotli where your host supports it.
  • Remove build output, caches, and duplicate files before compressing, since the cheapest bytes to compress are the ones you leave out.