How to compress files and folders on Windows with compact.exe

Running out of disk space but can’t delete files or get a bigger hard drive? Here’s a way to get more space.

Running out of disk space on your Windows machine? If installing a larger storage drive or deleting files and folders isn’t an option, one of the best ways to create more space is to compress the files and folders on your computer. . The good thing is that Windows has a built-in utility you can use for this purpose called compact.exe.


Here’s how to use compact.exe to compress files and folders on your Windows PC to save disk space.

What is compact.exe on Windows?

In a nutshell, compact.exe is a Windows utility that reduces the size of files and folders on storage drives that use NTFS file system without losing data.

Depending on the type of compression you choose and the types of files compressed, you will get different degrees of compression. It can range from a few megabytes to entire gigabytes.

For already compressed file types, such as JPEG and ZIP, you won’t notice much difference in size (if any) when compressed with compact.exe. It can also make them slower to access. So it is better not to use the utility to compress these types of files.

Compact.exe uses advanced compression algorithms to compress files while ensuring that their contents are always accessible. These algorithms are, from fastest and least compact to slowest and most compact, XPRESS4K, XPRESS8K, XPRESS16K and LZX.

How to compress files with compact.exe

To use compact.exe, you will need a command line tool, either a command prompt or Windows PowerShell. We will use the latter.

To use compact.exe to compress files, follow the steps below.

  1. Hurry Win + S to launch Windows Search, then enter powershell in the search field.
  2. Click on WindowsPowerShell to launch the app.
  3. To compress a single file, you will need to enter a command with the structure below:
    compact [file path]

    just replace file path in square brackets above with the actual file path. In PowerShell it should look like the screenshot below.

    By default, compact.exe will use the XPRESS4K algorithm to compress the file. To use a specific algorithm, use the command structure below:

    compact /exe:[algorithm] [file path]

    You will need to replace algorithm in square brackets above with the name of the actual algorithm you want to use. So if you were to use the XPRESS8K algorithm, the command structure would be:

    compact /exe:XPRESS8K [file path]
  4. Hit it Walk in key and compact.exe will compress the file and show you the results.


As long as you follow the steps above, compressing a file with compact.exe should be a piece of cake.

How to compress folders with compact.exe

To use compact.exe to compress an entire folder, follow the steps below.

  1. Hurry Win + S to launch Windows Search, then enter powershell in the search field.
  2. Click on WindowsPowerShell to launch the app.
  3. In PowerShell, navigate to the directory or folder containing the files you want to compress. The command to do this has the following structure:
    cd [folder path]

    You just have to replace folder path in square brackets above with the actual directory path. Since the folder we want to compress is on the desktop, the screenshot below shows what the command looks like in PowerShell.

  4. Once PowerShell is in the desired directory, enter the command below:
    compact /c

    By default, compact.exe will use the XPRESS4K algorithm to compress the folder. To choose a different algorithm, use the following command structure:

    compact /exe:[algorithm]

    Replace algorithm in square brackets above with the name of the actual algorithm you want to use. So if you want to use the XPRESS8K algorithm, here’s what the command you would enter in PowerShell would look like:

    compact /exe:XPRESS8K
  5. press the Walk in key, and the utility will compress the files in the folder and then display the compression results.


It’s as easy as using compact.exe to compress folders on Windows.

Natively compress files and folders on Windows

When you’re running out of storage space on your Windows computer, there are lots of things you can do to create more space without adding a bigger disk or deleting files you might need later.

With compact.exe, you can compress files with a simple command in Command Prompt or PowerShell. You don’t even have to use a third-party compression tool. If you prefer a more graphical way of using compact.exe, you can check out CompactGUI.