Last updated:
Quick answer: on Windows 10 (build 17063 and later) and Windows 11, create a zip from Command Prompt or PowerShell with tar -a -c -f archive.zip file.txt and extract it with tar -x -f archive.zip. The -a flag matters: without it, tar writes a tar archive and only names it .zip. In PowerShell you can also use Compress-Archive and Expand-Archive.
tar -a -c -f archive.zip file.txt
tar -x -f archive.zip
Windows has no built-in zip or unzip command in Command Prompt, so the choice is between three tools. The table shows which one fits which job.
| Tool | Works in | Best for | Create a zip | Extract |
|---|---|---|---|---|
tar (bsdtar) | CMD and PowerShell | Quick zips with nothing to install; also reads .tar.gz, .7z and more | tar -a -c -f out.zip files | tar -x -f out.zip |
Compress-Archive / Expand-Archive | PowerShell only | Scripts; control over compression level and overwrite | Compress-Archive -Path files -DestinationPath out.zip | Expand-Archive -Path out.zip -DestinationPath folder |
7z (7-Zip) | CMD and PowerShell after install | Passwords, .7z, huge or unusual archives | 7z a -tzip out.zip files | 7z x out.zip |
Commands on this page were checked as follows: the tar and 7z commands were run with bsdtar 3.7.2 and 7-Zip 23.01 on Ubuntu 24.04. The tar.exe that ships with Windows is built from the same libarchive project (Microsoft says it is based on bsdtar), but I did not run it on a Windows machine for this update. The PowerShell parameters come from Microsoft Learn and were not run today. The screenshots were taken on Windows in February 2024.
Zip and unzip with tar
Microsoft added tar to Windows 10 in Insider build 17063, and it is based on bsdtar from the libarchive project. Run tar --version to confirm it is there. Open the folder that holds your files first:
cd C:\Users\Ali\Documents
dir

cd into the folder, then dir to see the files.Create a zip file with tar -a
tar -a -c -f files.zip file.txt
-a (auto-compress) picks the archive format from the file extension, -c creates, and -f names the output. To zip several files or a whole folder, list them after the name:
tar -a -c -f archive.zip file.txt b.txt
tar -a -c -f docs.zip docs
Folders are added with everything inside them. In my test the folder case listed docs/ and docs/x.txt inside the archive.
Common mistake: tar -c -f files.zip file.txt (without -a) does not create a zip. In my bsdtar 3.7.2 test it produced a POSIX tar archive named files.zip, and an empty file came out at 1,536 bytes, against 198 bytes with -a. The screenshot below shows that 1,536-byte size on Windows. Tools such as Explorer or an email filter may not open that file as a zip. Always add -a.

-a. The 1,536-byte files.zip is the size of a tar archive holding an empty file; the same command with -a gives a real zip.Unzip with tar
tar -x -f files.zip
dir
-x extracts. You do not need -a here because tar detects the format itself. To extract into another folder, the folder has to exist already:
mkdir C:\Users\Ali\extracted
tar -x -f files.zip -C C:\Users\Ali\extracted
In my test, -C pointing to a folder that did not exist stopped with could not chdir. To only look inside an archive, run tar -tf files.zip (add v for sizes and dates).

tar -xf and checking the folder with dir.Zip and unzip with PowerShell
PowerShell has two cmdlets for this. They work in Windows PowerShell and in PowerShell 7, but not in Command Prompt.
Compress-Archive -Path C:\Users\Ali\Documents -DestinationPath C:\Archives\Draft.zip -CompressionLevel Fastest

dir C:\Archives

Expand-Archive -Path C:\Archives\Draft.zip -DestinationPath C:\Users\Ali\Documents

Details from the Microsoft Learn pages for Compress-Archive and Expand-Archive that cause most surprises:
| Behavior | What to know |
|---|---|
| Folder path vs wildcard | -Path C:\Reference includes the folder itself in the zip. -Path C:\Reference\* zips its contents without the top folder. |
| Compression level | Optimal (default), Fastest or NoCompression. |
| Existing archive | -Force overwrites it. -Update replaces older same-named files and can add files to the existing zip. The two cannot be combined. |
| Missing .zip extension | If the destination name has no .zip extension, the cmdlet adds it. |
| Hidden files | Hidden files and folders are ignored when creating or updating the archive. |
| 2 GB limit | Both cmdlets use the ZipArchive API, which limits the maximum file size to 2 GB. Use 7-Zip for larger files. |
| Expand-Archive overwrite | Existing files are not overwritten unless you add -Force. A missing destination folder is created. |
Zip and unzip with 7-Zip
7-Zip is useful for password-protected archives, the .7z format and very large files. Install it from 7-zip.org, or with Chocolatey if you already use it:
Stuck at this step? Ask us, it is free and include the exact error.
choco install 7zip.install -y

If 7z is not recognized afterwards, open a new terminal window so the updated PATH loads, or run it with its full path in C:\Program Files\7-Zip.
The original version of this guide used -t7z, which creates a .7z file, not a zip. For a real zip use -tzip:
7z a -tzip files.zip *.txt
7z a -t7z files.7z *.txt

-tzip instead if you need a .zip.To extract, x keeps the folder structure and e puts every file into one flat folder. In my test of a zip containing docs/x.txt, 7z x restored docs\x.txt and 7z e placed x.txt directly in the output folder. Use -o (no space) to choose the folder:
7z x files.zip -oC:\Users\Ali\extracted
7z l files.zip
7z l lists the contents without extracting.

7z e in the current folder.Verify the archive
Before you delete the originals or send the zip, list what is inside. Both of these commands only read the file:
tar -tf archive.zip
7z l archive.zip
The names you expect should appear. For Linux archives, see the guide to extracting .tar.gz files with tar. To read an extracted text file straight from the terminal, use the cat command in Windows. If the archive holds sensitive material, the cipher command in Windows can also wipe the leftover copies.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
tar is not recognized | Windows older than Windows 10 build 17063 | Update Windows, or use 7-Zip. |
| The .zip made with tar will not open in Explorer or another tool | Created without -a, so it is a tar archive | Recreate it with tar -a -c -f name.zip files. |
could not chdir when using -C | The target folder does not exist | Create it with mkdir first. |
| Files are missing from a Compress-Archive zip | Hidden files are skipped | Use 7-Zip or tar -a -c if hidden files must be included. |
| Expand-Archive leaves old files unchanged | Existing files are not overwritten by default | Add -Force. |
| Compress-Archive fails on a very large file | 2 GB file-size limit | Use 7z a -tzip or tar -a -c -f. |
7z is not recognized | 7-Zip is not on PATH in this window | Open a new terminal, or run it from C:\Program Files\7-Zip. |
Frequently asked questions
Is there a zip command in Windows Command Prompt?
No. Command Prompt has no zip or unzip command. Use tar -a -c -f, PowerShell’s Compress-Archive, or 7-Zip.
Does tar on Windows create a real .zip file?
Yes, but only with -a. Without it, my bsdtar test produced a tar archive that merely had a .zip name.
How do I unzip to a specific folder?
With tar use -C folder (the folder must exist), with PowerShell use -DestinationPath folder, and with 7-Zip use -ofolder.