Can 7-Zip Create TAR.GZ and TAR.XZ Files?

7-Zip can create compressed tarball archives such as .tar.gz and .tar.xz, but doing so through the standard graphical interface requires a two-step process rather than a single-click export. This article explains the technical reason for this design and provides the exact steps to generate both formats using the 7-Zip interface and the command-line utility.

Why 7-Zip Requires Two Steps

TAR is an archiving format that bundles multiple files into a single container without applying compression. Conversely, GZ (Gzip) and XZ are compression algorithms designed to compress only single files, not directories or file groups. Because 7-Zip handles archiving and compression as distinct operations, you cannot directly select a folder and compress it into .tar.gz or .tar.xz in one prompt using the standard GUI.

How to Create TAR.GZ or TAR.XZ via the GUI

To create these formats using the 7-Zip graphical interface, you must pack the files into a .tar container first, then compress that container.

  1. Create the TAR file:

    • Select the files or folders you want to include.
    • Right-click and choose 7-Zip > Add to archive...
    • Under Archive format, select tar.
    • Click OK to generate the .tar file.
  2. Compress the TAR file:

    • Right-click the newly generated .tar file.
    • Choose 7-Zip > Add to archive...
    • Under Archive format, select gzip (for .tar.gz) or xz (for .tar.xz).
    • Click OK.

7-Zip will automatically append the compression extension to the file, producing your final .tar.gz or .tar.xz archive.

Creating Tarballs in One Step via Command Line

If you use the 7-Zip command-line tool (7z), you can pipe the output to avoid manually saving an intermediate .tar file to disk.

For TAR.GZ:

7z a -ttar -so archive.tar "C:\Path\To\Files\*" | 7z a -si archive.tar.gz

For TAR.XZ:

7z a -ttar -so archive.tar "C:\Path\To\Files\*" | 7z a -txz -si archive.tar.xz

The -so switch directs the uncompressed TAR data to standard output, while -si instructs the second command to read that stream and compress it directly to the final archive.