← All posts
WindowsPublished · 6 min read

How to Extract .tar.gz on Windows 11 Without 7-Zip — and Fix "Invalid empty pathname" (Tested)

A .tar.gz from a Linux server, a GitHub release or a backup job lands in Downloads and Windows doesn't seem to know what to do with it. It does: Windows 11 can open these archives in File Explorer, and every Windows 10/11 PC has a tar command. I built the same folder into six tar variants on a Windows 11 PC and extracted each one, then built a tar the way GNU tar on Linux does - with non-ASCII file names - and watched Windows' tar refuse every file in it.

What .tar, .tar.gz and .tgz actually are

A .tar joins many files and folders into one file without compressing them. A .tar.gz (also written .tgz) is that tar compressed with gzip; .tar.bz2, .tar.xz and .tar.zst use bzip2, xz and zstd instead. I packed a test folder (4 files, 301,816 bytes, Korean file names) with Windows' own tar and read the first bytes of each result:

FileCompressionFirst bytesSize (bytes)
.tarnoneustar at byte 257313,344
.tar.gz / .tgzgzip1F 8B301,012
.tar.bz2bzip242 5A 68 (BZh)302,836
.tar.xzxzFD 37 7A 58 5A 00302,248
.tar.zstzstd28 B5 2F FD300,724

The plain .tar was slightly *larger* than the source - it only packs. The compressed sizes barely moved here because 300,000 of the bytes were random data; folders of text and documents shrink much more.

Way 1: File Explorer (Windows 11 24H2 and later)

Two built-in ways - Explorer for a click, tar for scripts and older builds
  1. 1Right-click the .tar.gz (or .tar, .tgz, .tar.xz…).
  2. 2Choose Extract All…, pick a destination, and extract.

Microsoft's support page "Zip and unzip files" states that Windows 11, version 24H2 supports ZIP, RAR, 7z and TAR, and that it does not support operations on encrypted archives. On this PC (Windows 11 build 26300) all six variants above opened as compressed folders, and extracting the .tar.gz through Explorer gave back all 4 files with their Korean names intact.

💡

If another archiver is installed, double-clicking may open that program instead - on this PC .tar and .gz were associated with ALZip. Use the right-click menu to stay in Explorer.

Way 2: tar -xf (any Windows 10 or 11)

Windows has shipped tar since Windows 10 Insider build 17063 (Microsoft's command-line blog, January 2018). On this PC, C:\Windows\System32\tar.exe reported bsdtar 3.8.9 - libarchive 3.8.9. Open Command Prompt or PowerShell in the folder with the archive:

text
tar -xf archive.tar.gz

To extract somewhere else, add -C and a folder. The folder has to exist - pointing at a missing one failed with tar.exe: could not chdir to '…'.

text
tar -xf archive.tar.gz -C C:\Users\you\Desktop\unpacked

To look inside first, use -t instead of -x:

text
tar -tf archive.tar.gz

You don't need -z, -j or -J when extracting: the same -xf extracted all six variants. It even extracted a .zip I had renamed to .tar, so it goes by the file's content, not its extension. The same tar.exe also reads RAR and 7z archives (there's a separate guide on that here).

"Invalid empty pathname": tar files made on Linux

GNU tar on Linux writes file names as raw UTF-8 bytes in its default format. I built such an archive with Python's tarfile (GNU format, UTF-8 names, no PAX headers) and extracted it with Windows' tar on this PC. Every entry failed and nothing was extracted (exit code 1):

text
> tar -xf linux_gnu.tar -C out
?먮즺/: Invalid empty pathname: Unknown error
?먮즺/readme.txt: Invalid empty pathname: Unknown error
?먮즺/蹂닿퀬??理쒖쥌.txt: Invalid empty pathname: Unknown error
...

The names are UTF-8 read as the PC's legacy code page. Telling libarchive which character set the headers use fixed it - all 4 files came out with their original names:

text
tar --options hdrcharset=UTF-8 -xf linux_gnu.tar -C out
Same Linux-style tar: plain -xf extracted nothing; hdrcharset=UTF-8 or Explorer extracted everything
  • libarchive's archive_read_set_options(3) lists hdrcharset for the tar reader: "The value is used as a character set name that will be used when translating file names."
  • File Explorer's Extract All extracted the same archive with correct names (2.8 seconds here), with no options.
  • tar -tf on that archive printed the same garbled names with exit 0 - a quick way to spot the problem before extracting.
  • Archives made by Windows' tar and PAX-format archives extracted fine without the option. Windows' tar wrote a PAX header for the non-ASCII names (the file starts with PaxHea).
⚠️

I tested on a Windows PC set to Korean (code page 949). On a PC with a different system locale, the same archive may fail differently or extract with garbled names instead - I didn't test that. Archives with ASCII-only names are not affected.

Other errors I hit

MessageCauseFix
Error opening archive: Unrecognized archive formatA plain .gz (one gzipped file, not a .tar.gz)Explorer's Extract All extracted it; or rename/decompress it as a single file
could not chdir to '…'The -C folder doesn't existCreate the folder first
Error opening archive: Failed to open '…'Wrong name or wrong foldercd to the archive's folder or give the full path
Invalid empty pathnameLinux tar with UTF-8 names--options hdrcharset=UTF-8, or Explorer
Asks for a passwordEncrypted archive - Explorer doesn't support it (Microsoft)A third-party archiver such as 7-Zip

If Git for Windows is installed, typing tar inside Git Bash runs Git's GNU tar 1.35 (C:\Program Files\Git\usr\bin\tar.exe), not Windows' bsdtar. That one extracted the Linux-style archive without any option.

FAQ

Q. Do I need 7-Zip or WinRAR to open .tar.gz on Windows?

Not for normal archives. Windows 11 24H2+ extracts them in File Explorer, and tar -xf works on Windows 10 and 11. You need a third-party tool for password-protected archives, which Explorer doesn't support.

Q. Is .tgz different from .tar.gz?

No - it's the same gzip-compressed tar with a shorter extension. Windows' tar produced byte-for-byte the same size (301,012 bytes) for both from the same folder.

Q. Why does tar say "Invalid empty pathname"?

In my test it happened with a tar made the GNU/Linux way, whose file names are UTF-8 without a PAX header. Windows' tar couldn't convert the names and skipped every entry. Run tar --options hdrcharset=UTF-8 -xf file.tar, or extract it with File Explorer.

Q. How do I extract a .tar.gz to a specific folder?

tar -xf file.tar.gz -C D:\target - create D:\target first, because tar won't create it and stops with "could not chdir".

Comments 0

No comments yet. Be the first.

Only members can comment.

Comments with ads, abuse, personal information or illegal content are hidden or removed. Members who post ads, spam, or hateful content are removed from the site, and everything they wrote is deleted. Comments are shown with your nickname. Privacy Policy

More posts