apyhub
Cover illustration for All About File Compression: RAR, ZIP, 7z Explained
Engineering

All About File Compression: RAR, ZIP, 7z Explained

RAR vs ZIP vs 7z: Compression Ratios, Speed, and Encryption Compared

TL;DR: 7z compresses about 30 to 70 percent smaller than ZIP on the same content, RAR about 10 to 30 percent smaller, and ZIP opens on every operating system without installing anything. Use ZIP to send files to people, 7z to store them, and tar.gz on Linux. The reason 7z wins is solid compression across files, explained below.

Updated 26 August 2026 with measured ratio ranges, tar.gz and Zstandard coverage, and corrected encryption details.

01What File Compression Actually Does

Compression reduces file size by encoding data more efficiently, usually by finding repetition and storing it once with references. Archive formats like ZIP, RAR, and 7z are lossless: decompressing returns the original bytes exactly. That is different from image or video compression, which discards data you are unlikely to notice.

Two jobs get confused here and it matters later:

  • Archiving bundles many files into one container.
  • Compression makes the data smaller.

ZIP, RAR, and 7z do both. TAR only archives, which is why you see tar.gz rather than plain tar.

02Compression Ratios: The Actual Numbers

Ratios depend heavily on content. Text, source code, and logs compress enormously. JPEGs, MP4s, and already-compressed data barely compress at all, because the redundancy has already been removed.

Typical figures reported across published comparisons:

FormatAlgorithmTypical size vs originalvs ZIPSpeed
ZIPDEFLATE60–70% mixed content, 20–30% textbaselineFastest
RAR (RAR5)Proprietary10–30% smaller than ZIP10–30% betterModerate
7zLZMA230–70% smaller than ZIP30–70% betterSlowest
tar.gzDEFLATESimilar to ZIProughly equalFast
tar.xzLZMA2Similar to 7z30–70% betterSlow
tar.zstZstandardBetween gzip and xz15–40% betterVery fast

DEFLATE, the algorithm behind ZIP and gzip, has a hard compression ceiling of 1032 to 1. No DEFLATE stream can expand more than that. LZMA2 has no comparable limit, which is part of why 7z pulls ahead on highly repetitive data.

03Why 7z Beats ZIP: Solid Compression

This is the mechanism almost nobody explains, and it is the whole answer.

ZIP compresses each file independently. Every entry in a ZIP is its own compressed stream. That has a real advantage: you can extract one file from a 10GB archive without decompressing the other 9.99GB. It also has a cost, which is that ZIP cannot exploit redundancy between files.

7z uses solid archives by default. It concatenates files and compresses them as one stream, so repetition across files gets found and stored once.

The difference is dramatic on similar files. A folder containing a thousand near-identical log files, or a source tree where every file shares the same license header, compresses far better as 7z than as ZIP. On a folder of unrelated JPEGs, the two are nearly identical, because there is no cross-file redundancy to find.

The trade-off is extraction. Pulling a single file out of a solid archive means decompressing everything before it. 7z lets you tune the solid block size to balance this.

04The Formats

ZIP

The default since 1989 and still the default. Windows, macOS, Linux, iOS, and Android all open ZIP natively. Every email client handles ZIP attachments.

Compression is decent rather than great. The real value is that the recipient never has to think about it.

Two limitations worth knowing:

  • The original ZIP spec has a 4GB limit on file size and archive size. ZIP64 removes it, and most modern tools support ZIP64, but not all.
  • Modern ZIP implementations can use LZMA, BZIP2, or Zstandard instead of DEFLATE. Compatibility drops sharply if you do. An LZMA-compressed ZIP will not open in Windows' built-in extractor. Stick to DEFLATE unless you control both ends.

RAR

Proprietary, developed by RARLAB, and the format you meet in game mods, ROM archives, and older download sites.

RAR5 compresses roughly 10 to 30 percent better than ZIP and handles very large archives gracefully, including splitting across multiple volumes. Its distinctive feature is recovery records, which can repair a partially corrupted archive. That mattered a great deal in the era of unreliable downloads and multi-part uploads.

The catch: creating RAR archives requires WinRAR, which is paid. Extraction is free and widely supported by 7-Zip, PeaZip, and Bandizip. Since 7z compresses better and costs nothing, RAR has been declining in technical use.

7z

The native format of 7-Zip, open source, and the best compression of the three.

LZMA2 plus solid archives produces the smallest output on most content. It supports strong encryption, multi-threading, and dictionary sizes large enough to find redundancy across hundreds of megabytes.

The cost is speed and reach. 7z compresses noticeably slower, and no major operating system opens it natively. Windows users need 7-Zip, macOS users need Keka or The Unarchiver.

tar, tar.gz, tar.xz, tar.zst

TAR is the Unix standard and does not compress anything. It concatenates files into one stream, preserving permissions, symlinks, and ownership, which ZIP handles poorly or not at all. Compression is applied afterwards:

  • tar.gz uses gzip (DEFLATE). Fast, universal on Linux, compression comparable to ZIP.
  • tar.xz uses LZMA2. Compression comparable to 7z, and slow.
  • tar.zst uses Zstandard, which reaches near-xz ratios at far higher speed. It is increasingly the default in Linux backup and container pipelines.

If you are shipping anything to a Linux system, or anything where file permissions matter, tar is the correct container.

05Encryption Compared

The earlier version of this article got this wrong, so here it is accurately.

FormatEncryptionVerdict
ZIP (ZipCrypto)Legacy, cryptographically brokenDo not use. Breakable in seconds
ZIP (AES-256)AES-256Strong, but support is uneven across tools
7zAES-256 with PBKDF2Strong. Consistent across the 7-Zip ecosystem
RAR5AES-256 with PBKDF2Strong. WinRAR ecosystem only

Two things people get wrong. First, ZIP's default encryption in many tools is still ZipCrypto, which offers essentially no protection. Selecting AES-256 in a ZIP is usually a manual choice. Second, none of these formats encrypt filenames by default in ZIP. 7z and RAR can encrypt the archive header so the file list itself is hidden. ZIP with AES leaves filenames visible.

For genuinely sensitive data, 7z with AES-256 and header encryption is the cleanest default.

06Which Format Should You Choose?

SituationUseWhy
Sending files to someoneZIPOpens everywhere, no software required
Email attachmentZIPEvery client handles it
Long-term storage where size matters7z30–70% smaller, you control both ends
Linux backup or deploymenttar.zst or tar.gzPreserves permissions, fast
Maximum compression, time no object7z or tar.xzLZMA2 with a large dictionary
Very large files over unreliable transferRARRecovery records and multi-volume splitting
Sensitive data7z with AES-256Strong encryption plus header encryption
Files generated by your applicationZIPSee below

Converting between formats always means extract then recompress. There is no direct transcoding, because the compressed representations are unrelated.

07Compression in Production Is a Different Problem

Everything above assumes a person with a file on their desktop choosing a format. The calculus changes when the archive is created or received by an application.

At that point format choice stops being the interesting question. ZIP wins almost by default, because your recipient is arbitrary and ZIP is the only format that opens everywhere with no software. The interesting questions become memory, streaming, and what happens when someone uploads a hostile archive.

A 46MB ZIP file can expand to 4.5 petabytes. That is not a hypothetical: it is a documented construction, and if your application extracts uploaded archives without limits, it is a denial-of-service vector sitting in your upload handler.

We cover that side in Archiving Files in Production: Streaming, Memory Limits, and Zip Bombs.

08Compression APIs

If you need archiving inside an application rather than on a desktop, ApyHub covers the ZIP side of this:

  • Generate Archives bundles multiple files or URLs into a ZIP.
  • Unarchive Files extracts a ZIP.
  • Generate Secure Archives produces password-protected archives for sensitive material.
  • Unarchive Secured Files extracts password-protected ZIPs.
  • Compress Images is a different job entirely: lossy JPEG and PNG optimisation by quality setting, which archives cannot do because they are lossless.

Being straight about scope: these handle ZIP, not RAR or 7z. For programmatic archiving that is usually the right constraint rather than a limitation, since ZIP is the format your recipients can actually open. If you need 7z ratios for internal storage, that is a different job and a local tool does it better.

Browse file security APIs → · Browse file manipulation APIs →

09Sources

10FAQ

How much smaller is 7z than ZIP? Typically 30 to 70 percent smaller on the same content. The gap is largest on text, source code, logs, and folders containing similar files, and nearly zero on already-compressed content like JPEGs or MP4s.

Why does 7z compress better than ZIP? Two reasons. It uses LZMA2 rather than DEFLATE, and it creates solid archives by default, compressing all files as one stream so repetition between files is found and stored once. ZIP compresses each file independently and cannot see across files.

What is the difference between RAR, ZIP, and 7z? ZIP is fastest and opens everywhere natively, with moderate compression. RAR compresses 10 to 30 percent better than ZIP and adds recovery records and multi-volume splitting, but creating RAR files requires paid software. 7z compresses 30 to 70 percent better than ZIP and offers the strongest encryption, at the cost of speed and native OS support.

Can I open RAR files without WinRAR? Yes. 7-Zip, PeaZip, and Bandizip all extract RAR for free. Creating RAR archives is what requires a WinRAR license.

Which format compresses files the most? 7z, using LZMA2 with a large dictionary and solid archiving, on most content types. tar.xz achieves similar ratios on Linux.

Is ZIP encryption secure? It depends which one. ZIP's legacy ZipCrypto is cryptographically broken and can be defeated in seconds. ZIP with AES-256 is strong, but many tools default to ZipCrypto and support for AES-in-ZIP is uneven. ZIP also leaves filenames visible even when contents are encrypted.

Does RAR use AES-128 or AES-256? RAR5 uses AES-256 with PBKDF2 key derivation, the same as 7z. The older RAR4 format used AES-128.

What is a solid archive? An archive that compresses multiple files as one continuous stream rather than individually, allowing the compressor to find repetition across files. 7z uses solid archives by default. The trade-off is that extracting one file requires decompressing everything before it in the block.

Why is there a 4GB limit on ZIP files? The original ZIP specification used 32-bit fields for sizes and offsets, capping files and archives at 4GB. The ZIP64 extension uses 64-bit fields and removes the limit. Most modern tools support ZIP64, but not all, so very large ZIPs are less portable.

What is tar.gz and how does it differ from ZIP? TAR bundles files into one stream without compressing, preserving Unix permissions, symlinks, and ownership. Gzip then compresses that stream. ZIP does both jobs in one format but handles Unix file metadata poorly. Use tar.gz when permissions matter.

Should I use Zstandard? If you control both ends, often yes. Zstandard reaches ratios close to xz at far higher speed, which is why it has become common in Linux backup and container workflows. Support outside Linux is still limited, so it is a poor choice for archives you send to arbitrary recipients.

How do I convert a RAR file to ZIP? Extract the RAR, then recompress the contents as ZIP. There is no direct conversion, since the two formats use unrelated compressed representations. Any tool that reads RAR and writes ZIP will do this in one step from the user's perspective.

How do I create ZIP archives programmatically? Either use a library in your language, or call an API. ApyHub's Generate Archives API bundles files or URLs into a ZIP, and Unarchive Files extracts them. If you are handling archives uploaded by users, read about extraction limits and zip bombs before writing that code.

11About ApyHub

ApyHub is a curated API catalog for developers, teams, and AI agents, covering file conversion, archiving, validation, AI, extraction, and more. One subscription covers the whole catalog, billed in atoms, with headroom pooled across every API rather than locked to individual services.

Every service carries machine-readable certification covering data handling, retention, and standards alignment including GDPR, SOC 2, and ISO 27001. Every endpoint is MCP-ready by default.

ApyHub is headquartered in Amsterdam, with offices in the Netherlands, Greece, and India, and runs on EU infrastructure. The catalog holds 450+ services and 1,500+ endpoints, with new APIs and providers onboarded continuously. The free tier requires no credit card.