How to open a .gz file
A .gz file is a single file compressed with gzip: report.csv.gz holds report.csv. On a Mac, double-click it or run gunzip -k in Terminal; on Windows use 7-Zip; on Linux, gunzip -k. Any browser can open it with openrar.app, nothing installed.
A .gz file is one file compressed with gzip. The name tells you what’s inside: report.csv.gz decompresses to report.csv, and access.log.2.gz to access.log.2. To open it on a Mac, double-click it, or run gunzip -k in Terminal. On Windows, 7-Zip opens it; on Linux, gunzip -k does. On any device, including a phone or a Chromebook, you can also open it in the browser.
What a .gz file is
gzip is one of the oldest and most widely used compressors. It takes a single file and makes it smaller, nothing more: no folders, no list of contents, no password. Some typical examples:
- Log files. Servers keep old logs as
access.log.2.gz,syslog.3.gzand so on. - Database dumps and exports, such as
backup.sql.gzororders.csv.gz. - Data downloads from research and government sites.
- Web traffic. Many websites send their pages gzip-compressed, and your browser unpacks them without you noticing.
Text compresses very well with gzip, often to a tenth of its size or less. Keep that in mind with large files: a 300 MB .gz log can become several gigabytes once decompressed.
.gz or .tar.gz?
A .tar.gz (or .tgz) file is a different case. There, many files and folders are first packed into one with tar, and the result is compressed with gzip. If you decompress a .tar.gz with plain gunzip, you get a .tar file, which you then unpack to reach the files.
| File | Inside | One step to open it |
|---|---|---|
notes.txt.gz |
One file, notes.txt |
gunzip -k notes.txt.gz |
project.tar.gz, project.tgz |
Many files and folders | tar -xf project.tar.gz |
If you’re not sure which you have, gunzip -l file.gz in Terminal shows the name of the decompressed file; if it ends in .tar, it’s a tar archive. For that case, How to open .tar.gz files on a Mac has the details.
On a Mac
Double-click
Archive Utility, built into macOS, handles .gz files. Double-click the file in Finder, and the decompressed file appears next to it. If another app opens instead, Control-click the file, choose Open With, then Archive Utility.
Terminal
cd ~/Downloads
gunzip -k report.csv.gz
This writes report.csv next to the original. The -k option keeps the .gz file; without it, gunzip deletes the .gz once it has decompressed it. gzip -dk report.csv.gz does exactly the same thing. If a file with the decompressed name already exists, gunzip won’t silently overwrite it.
To read a compressed text file without writing anything to disk, use gzcat:
gzcat access.log.2.gz | less
On macOS, zcat is meant for the older .Z format and complains about .gz files, so stick with gzcat there.
On Windows
7-Zip, free and open source, opens every .gz file. After installing it from 7-zip.org, right-click the file and choose 7-Zip, then Extract Here. On Windows 11 you may need to choose Show more options first to see the 7-Zip entries. With a .tar.gz, 7-Zip first gives you the .tar; extract that too to get the files.
File Explorer in recent versions of Windows 11 opens many archive formats on its own, including .tar.gz. Whether it offers to extract a single .gz file depends on your version; if it doesn’t, use 7-Zip.
Windows 10 and 11 also include a tar command, which unpacks .tar.gz archives in one step from Command Prompt or PowerShell:
tar -xf project.tar.gz
On Linux
gzip is part of practically every Linux system:
gunzip -k report.csv.gz
On a very old system whose gzip doesn’t know -k, gzip -dc report.csv.gz > report.csv gives the same result. On Linux, zcat file.gz | less reads a compressed text file, and zgrep searches it. On the desktop, the archive manager handles .gz with a double-click: File Roller on GNOME, Ark on KDE.
In your browser, on any device
OpenRAR’s online tool opens single .gz files, as well as .tar.gz, .tgz and other archives, right in the page. Choose the file, and the decompressed file appears in the list; save it with one click. For a .tar.gz, you see every file and folder, and can save them one by one or all as a ZIP.
Nothing is uploaded: the file is decompressed on your device, inside the browser. That makes it a good choice on a Chromebook, a phone, or a work computer where you can’t install anything.
The limits are those of the browser’s memory: about 2 GB per file on a computer and about 2.5 GB once decompressed, or about 500 MB and 1 GB on a phone. Because text compresses so well, a large log can go over the decompressed limit even when the .gz itself is small. For those, use gunzip in Terminal, which streams the data instead of holding it in memory.
Making a .gz file
To compress a file yourself on a Mac or Linux:
gzip -k bigfile.csv
This creates bigfile.csv.gz and keeps the original. For a folder, or anything you’ll send to someone on Windows, a ZIP or .tar.gz is a better fit; How to compress files on a Mac compares the formats.