You can create a TAR.GZ file on Windows 10 and 11 without installing anything. Open Command Prompt or PowerShell in the folder that contains what you want to pack and run tar -czf archive.tar.gz foldername. Windows has included tar.exe since Windows 10 version 1803. If you prefer to work from the right-click menu, an archive program that creates TAR and GZ files does the same job without typing commands. Either way, the result opens on any Linux server with tar -xzf.
This guide covers both methods, the options you are likely to need, and the Windows-to-Linux gotchas that cause trouble after you upload.
What a TAR.GZ file is
A TAR.GZ is two formats stacked together:
- TAR bundles many files and folders into one file, keeping the folder structure. It does not compress anything.
- GZ (gzip) compresses a single file. It cannot hold folders on its own.
Combined, you get one compressed file holding a whole folder tree. The extensions .tar.gz and .tgz mean the same thing. Related variants use other compressors: .tar.bz2 and .tar.xz usually come out smaller than .tar.gz but take longer to create.
Linux tools, hosting control panels, deployment scripts and package managers expect TAR.GZ far more often than ZIP, which is why you need it when you work with servers. If you are on the receiving end instead, see how to open a TAR.GZ file in Windows.
Method 1: The built-in tar command
- Open File Explorer and go to the folder that contains the folder you want to pack.
- Click the address bar, type
cmdand press Enter. A Command Prompt opens in that location. On Windows 11 you can also right-click empty space and choose Open in Terminal. - Run:
tar -czf mysite.tar.gz mysite - The new
mysite.tar.gzappears next to the folder.
What the letters mean:
| Option | Meaning |
|---|---|
-c | Create a new archive |
-z | Compress it with gzip |
-f name | Write to this file name (must come right before the name) |
-v | List each file as it is added (optional) |
-C folder | Change to this folder before adding files |
--exclude=pattern | Leave out matching files or folders |
-tzf name | List the contents of an existing TAR.GZ without extracting |
Useful variations
- Pack the contents, not the folder itself:
tar -czf mysite.tar.gz -C mysite .puts the files at the top level of the archive, which some hosting panels expect. - Leave out folders you do not want to upload:
tar -czf mysite.tar.gz --exclude=node_modules --exclude=.git mysite - Pack several items:
tar -czf bundle.tar.gz config.json scripts docs - Check the result:
tar -tzf mysite.tar.gzlists every path inside.
Put the archive name directly after -f. Writing -cfz instead of -czf makes tar treat the letter z as the file name, which produces a confusing error or an oddly named file.
Method 2: An archive program
If you would rather not use the command line, or you need TAR.BZ2 or TAR.XZ as well, an archive program handles it from the right-click menu. Universal Zip creates TAR, GZ, BZ2 and XZ archives:
- Right-click the folder and choose Add to archive (under Show more options on Windows 11 if needed).
- Choose TAR as the format to bundle the folder into one
.tarfile. - Right-click the new
.tarfile, choose Add to archive again and pick GZ, BZ2 or XZ to compress it. - Delete the intermediate
.taronce the compressed file is created.
Before uploading, open the finished archive and browse it to confirm the folder layout is what the server expects. Universal Zip can also test the archive for damage, which is worth doing before you upload a large file over a slow connection.
Gotchas when the archive is going to Linux
File permissions
Windows does not use Unix permissions, so a TAR made on Windows cannot carry the correct ones. Scripts that need to be executable will not be, and some files may be more open than you want. After extracting on the server, set permissions explicitly, for example chmod 755 for folders and scripts and chmod 644 for ordinary files, or follow your application's instructions.
Line endings in scripts
Text files edited on Windows usually end lines with CR LF, while Linux expects LF. A shell script with Windows line endings fails with errors like /bin/bash^M: bad interpreter. tar does not convert line endings. Save scripts with LF endings in your editor, or convert them on the server with dos2unix or sed -i 's/\r$//' script.sh.
Case sensitivity
Windows treats Logo.PNG and logo.png as the same file. Linux does not. If your code refers to logo.png but the file is Logo.PNG, it works on your PC and breaks on the server. Check names before you pack.
Hidden and dot files
Files like .htaccess and .env are included by tar, which is usually what you want for a website, and sometimes exactly what you do not want. Exclude secrets you should not upload, such as local .env files with passwords.
Very long paths
Deep folder trees, such as JavaScript dependency folders, can exceed Windows' 260-character path limit and cause errors while packing. Exclude folders that the server will rebuild itself, or pack from a short location such as C:\build.
Checking the archive on the server
After uploading, list the contents with tar -tzf mysite.tar.gz | head before extracting, so you can see whether everything sits inside a top-level folder or at the root. Then extract with tar -xzf mysite.tar.gz, adding -C /path/to/target to choose the destination.
TAR.GZ, ZIP or 7Z?
Use TAR.GZ when the destination is a Linux server, a hosting panel or a tool that asks for it. Use ZIP when the archive is for people on mixed computers. Use 7Z when size matters most and the recipient has an archive program. Our ZIP vs 7Z vs RAR comparison goes into the trade-offs, and the archive file formats list covers the TAR variants alongside everything else.
Frequently asked questions
Can Windows create tar.gz files?
Yes. Windows 10 and 11 include tar.exe, and tar -czf archive.tar.gz folder creates one from Command Prompt or PowerShell.
Why use tar.gz instead of zip for Linux?
It is the standard on Linux, every server can extract it with tar, and it is the format many deployment and hosting tools expect.
Do Linux file permissions survive in a tar made on Windows?
Not in a meaningful way, because Windows does not store Unix permissions. Set permissions on the server after extracting.
