How to Compress a File: Complete Step-by-Step Guide
— Written by Brendan G., Founder & Developer
File compression reduces file sizes so they're easier to store, send by email, or share online. This guide walks through every method for compressing files on Windows, Mac, Linux, and online — including which format to use and when.
Need to compress a file right now?
Open Free File Compressor →No account required. Works in your browser.
What Does Compressing a File Do?
File compression is the process of reducing a file's size by encoding its data more efficiently. When you compress a file, a compression algorithm scans the file's contents and finds patterns that can be represented with fewer bits. For example, if a text file contains the word "the" thousands of times, the compressor substitutes a short token for each occurrence instead of storing all three letters every time. The result is a smaller file that contains the same information in a denser form.
There are two broad types of compression: lossless and lossy. Lossless compression — used by ZIP, 7z, RAR, and other archive formats — reduces file size without discarding any data. When you decompress a losslessly compressed file, you get back exactly the original bytes. Lossy compression — used by JPEG images, MP3 audio, and MP4 video — achieves higher compression ratios by permanently discarding data that's less perceptible to human senses. For most file-sharing and archiving purposes, you want lossless compression because it preserves the integrity of your files completely.
How much a file compresses depends entirely on its content type. Plain text files, log files, Word documents, and uncompressed images often compress by 60% to 80% — a 10 MB text file might become a 2 MB ZIP archive. Executable files (.exe, .dll) typically compress by 40% to 60%. Already-compressed files like JPEG photos, MP3 audio, and MP4 videos compress by almost nothing — usually 1% to 5% — because the compression algorithm can't find much redundancy in data that's already been compressed. Compressing a ZIP file of ZIP files will barely shrink it at all.
How to Compress a File on Windows (Built-in)
Windows includes built-in ZIP compression through File Explorer — no extra software required. Here's exactly how to use it:
To compress a single file:
- Locate the file you want to compress in File Explorer.
- Right-click the file.
- In the context menu, hover over "Send to".
- Click "Compressed (zipped) folder".
- Windows creates a .zip file with the same name in the same location.
To compress multiple files into one archive:
- Select all the files you want to include (hold Ctrl and click each one, or Shift-click a range).
- Right-click any of the selected files.
- Choose "Send to" → "Compressed (zipped) folder".
- Windows bundles all selected files into a single .zip archive.
To compress an entire folder:
- Right-click the folder you want to compress.
- Choose "Send to" → "Compressed (zipped) folder".
- Windows compresses the folder and all its contents, preserving the internal folder structure.
The Windows built-in ZIP compression is fast and convenient, but it uses a basic compression level. If you need the smallest possible file, use 7-Zip (described below) which often achieves 30% to 50% better compression ratios than Windows' default.
On Windows 11, the right-click menu is slightly different. If you right-click a file or folder, you may see a "Compress to ZIP file" option directly in the first level of the menu, rather than buried under "Send to."
How to Compress a File on Windows Using 7-Zip (Better Compression)
7-Zip is a free, open-source compression tool that produces significantly smaller archives than Windows' built-in ZIP. It supports multiple formats including 7z (its own high-compression format), ZIP, TAR, and more. Download it at 7-zip.org — it's completely free.
Once 7-Zip is installed:
- Right-click the file or folder you want to compress.
- In the context menu, hover over "7-Zip".
- Click "Add to archive—" to open the full options dialog.
- Choose your archive format: 7z for maximum compression (best for storage/backup), zip for maximum compatibility (sharing with others).
- Set the Compression level: Normal is usually the right balance. Ultra gives the smallest file but takes more time and CPU.
- Click OK. 7-Zip creates the compressed archive.
Quick compress shortcuts in 7-Zip:
- "Add to [filename].7z" — one-click 7z compression with default settings
- "Add to [filename].zip" — one-click ZIP compression with default settings
- "Compress and email—" — compresses and opens your email client with the archive attached
How to Compress a File on Mac
macOS has built-in compression in Finder that creates .zip archives:
To compress a single file or folder:
- Locate the file or folder in Finder.
- Right-click (or Control-click) on it.
- Select "Compress [filename]" from the context menu.
- Mac creates a
filename.zipfile in the same folder.
To compress multiple files on Mac:
- Select all the files you want to compress (Command-click to select multiple).
- Right-click any selected file.
- Choose "Compress X Items" (where X is the number of files).
- Mac creates an
Archive.zipfile containing all selected items.
For better compression on Mac, The Unarchiver (free on the Mac App Store) and Keka (paid, or free from keka.io) support 7z and other formats. For command-line users, the built-in zip command or installing p7zip via Homebrew (brew install p7zip) gives access to 7-Zip's compression algorithms on macOS.
How to Compress a File on Linux
Linux offers the most flexible command-line compression options:
Create a ZIP archive:
zip archive.zip file.txt
zip -r archive.zip folder/
Create a TAR.GZ archive (most common on Linux):
tar -czf archive.tar.gz file.txt
tar -czf archive.tar.gz folder/
Create a 7z archive (requires p7zip: apt install p7zip-full):
7z a archive.7z file.txt
7z a archive.7z folder/
Maximum compression with 7z:
7z a -mx=9 archive.7z folder/
The -mx=9 flag sets compression to Ultra (level 9), the maximum available. For everyday use, -mx=5 (Normal) is usually sufficient and much faster.
How to Compress a File Online
If you don't want to install software, or you need to compress a file on a device where you can't install programs, online file compressors work directly in your browser.
FileShot's free File Compressor compresses files without uploading them to a server — compression happens in your browser using JavaScript, so your file content stays private. No account is required and there's no file size limit imposed by the tool itself.
- Go to fileshot.io/tools/compressor.
- Drag and drop your file onto the upload area, or click to browse.
- Select your compression format and level.
- Click Compress.
- Download the compressed file.
Compression Formats Compared: ZIP vs 7z vs RAR
Choosing the right compression format depends on your goal:
| Format | Compression | Compatibility | Best For |
|---|---|---|---|
| ZIP | Good | Universal (all OS) | Sharing with anyone |
| 7z | Excellent (30-70% better than ZIP) | Requires 7-Zip or similar | Backup, storage, maximum size reduction |
| RAR | Very Good | Requires WinRAR or 7-Zip | Multi-part archives, recovery records |
| TAR.GZ | Good | Native on Linux/Mac | Linux/Unix distributions, code archives |
| TAR.XZ | Excellent (similar to 7z) | Linux/Mac native, Windows needs tools | Linux package distribution |
The simple rule: Use ZIP when sharing files with people whose technical setup you don't know. Use 7z when you control both ends of the transaction and want the smallest possible file. Avoid RAR unless you have a specific need for its unique features (multi-part archives, recovery records) — 7z achieves similar compression without requiring proprietary software.
How to Compress a File to Email It
Email attachments are typically limited to 25 MB (Gmail) or 20 MB (Outlook). Compressing files before attaching them is often enough to get under this limit for documents, spreadsheets, and similar file types. Here's the workflow:
- Right-click the file or folder you want to email.
- Select Send to → Compressed (zipped) folder (Windows) or Compress (Mac).
- Check the size of the resulting .zip file.
- If it's under your email provider's limit, attach it directly to your email.
- If still too large, share the file via FileShot instead — upload the file, copy the link, and paste it into your email. FileShot supports files of any size and keeps them available for the recipient to download at their convenience.
Note that JPEG images, MP4 videos, MP3 audio files, and other already-compressed formats won't shrink much from additional ZIP compression — for these file types, you're better off sharing via a file-hosting link directly.
How to Password Protect a Compressed File
Both 7-Zip and WinRAR support encrypting compressed archives with a password. Windows' built-in ZIP does not support encryption.
Password protect with 7-Zip:
- Right-click the file or folder → 7-Zip → Add to archive—
- In the dialog, find the "Encryption" section on the right side.
- Enter a password in the "Enter password" and "Reenter password" fields.
- Set Encryption method to AES-256 (the most secure option).
- Optionally enable "Encrypt file names" to hide even the file names from anyone without the password.
- Click OK.
For sharing password-protected files online, FileShot's password protection feature adds an extra layer of security — the file is encrypted client-side with AES-256-GCM before upload, and recipients need both the link and the password to access it. The server never sees the decryption key.
Why Can't Some Files Be Compressed?
You may notice that compressing some files results in a .zip that's actually larger than the original. This is because those files are already compressed internally. Common examples:
- JPEG images (.jpg, .jpeg) — already compressed using lossy DCT compression
- MP4, MOV, AVI video — video codecs (H.264, H.265, VP9) compress heavily
- MP3, AAC, OGG audio — audio codecs apply aggressive compression
- PDF files — typically compressed at creation time
- PNG images — losslessly compressed using Deflate
- ZIP, RAR, 7z archives — obviously already compressed
- Encrypted files — encryption randomizes the data, eliminating patterns that compression relies on
For these file types, compression adds minimal value. The best approach is to share them directly through a file sharing service rather than trying to compress them further.
Tips for Maximum Compression
- Use 7z format instead of ZIP — 7z's LZMA2 algorithm consistently achieves 30-70% better ratios than ZIP's Deflate.
- Compress similar files together — compression algorithms find redundancy across files in the same archive. Multiple text files of similar content compress far better as a group than individually.
- Use Ultra compression level only when time isn't critical — Normal (level 5) often achieves 90% of Ultra's size reduction in a fraction of the time.
- Convert before compressing — saving a Word document as plain text before compressing removes Office formatting overhead, potentially shrinking it further.
- Don't compress already-compressed files — adding JPEG or MP4 files to an archive with "store only" (compression level 0) is faster and produces the same result as compressing them, since they won't shrink anyway.
- Remove unnecessary files first — deleting temp files, logs, and cache data before creating an archive reduces its size more than any compression setting.
Compressing Files vs. Sharing Them
Sometimes the goal isn't compression itself — it's making a file small enough to share. If the compressed file is still too large for email, or if you're dealing with file types that don't compress (videos, photos), a better approach is to upload directly to a file sharing service and share the link.
FileShot handles large files without size limits, encrypts them with AES-256-GCM before upload so the server is blind to your content, and generates shareable links that work immediately with no account required. For files that won't compress meaningfully, skipping compression entirely and sharing via encrypted link is faster and more private than wrestling with archiving tools.
Frequently Asked Questions
How do I compress a file on Windows?
Right-click the file → "Send to" → "Compressed (zipped) folder". For better compression, install 7-Zip (free), right-click → 7-Zip → "Add to archive—" and choose 7z format.
How do I compress a file on Mac?
Right-click the file in Finder and choose "Compress [filename]". For multiple files, select all of them first, then right-click and choose "Compress X Items".
What is the best compression format?
ZIP for sharing with others (universal compatibility). 7z for maximum compression when you control both ends. TAR.GZ for Linux/Unix systems.
How much does compression reduce file size?
Text files and documents: 50-80% reduction. Executables: 40-60% reduction. Already-compressed files (JPEG, MP4, MP3): 1-5% or none.
Can I compress a file online for free?
Yes — use FileShot's free File Compressor. Works in your browser with no software to install and no account required.
How do I compress a file to email it?
Right-click → "Send to" → "Compressed (zipped) folder" on Windows, or "Compress" on Mac. If still too large for email, upload to FileShot and share the link instead.
Need to share a large file?
FileShot encrypts files client-side and generates shareable links instantly. No account required, up to 10 GB per file free (up to 300 GB on paid plans).
Share a File Free →