Are you running out of disk space on your Windows machine? If installing a bigger 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 to that end 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 the NTFS file system without losing any data.

Depending on the type of compression you choose and the file types being compressed, you'll get varying degrees of compression. It can range from as little as a few megabytes to entire gigabytes.

For file types that are already compressed, such as JPEG and ZIP, you won't notice much size difference (if any) when they're compressed with compact.exe. It can also make them slower to access. So it's best not to use the utility to compress those types of files.

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

How to Compress Files With compact.exe

To use compact.exe, you'll need a command line tool—either Command Prompt or Windows PowerShell. We're going to use the latter.

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

  1. Press Win + S to launch Windows Search and then enter powershell in the search box.
  2. Click on Windows PowerShell to launch the app.
  3. To compress a single file, you'll have to enter a command with the structure below:
    compact [file path]
    Just replace file path in the square brackets above with the actual path to the file. In PowerShell, it should look like the screenshot below.
    compressing a file with compact.exe in windows powershell
    By default, compact.exe will use the XPRESS4K algorithm to compress the file. To use a specific algorithm, use the below command structure:
    compact /exe:[algorithm] [file path]
    You will need to replace algorithm in the above square bracket with the name of the actual algorithm you want to use. So if you were going to use the XPRESS8K algorithm, the command structure would be as follows:
    compact /exe:XPRESS8K [file path]
  4. Hit the Enter key and compact.exe will compress the file and show you the results.
    results of compressing using compact in windows powershell

As long as you follow the above steps, 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. Press Win + S to launch Windows Search and then enter powershell in the search box.
  2. Click on Windows PowerShell to launch the app.
  3. Within PowerShell, navigate to the directory or folder with the files you want to compress. The command to do that has the following structure:
    cd [folder path]
    You just have to replace folder path in the square brackets above with the actual path to the directory. Since the folder we want to compress is on the desktop, the screenshot below shows what the command looks like in PowerShell.
    changing folder directory in windows powershell using the cd command
  4. Once PowerShell is in the desired directory, enter the below command:
    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 the 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'd enter in PowerShell would look like:
    compact /exe:XPRESS8K
  5. Press the Enter key, and the utility will compress the files in the folder and display the compression results afterward.
    changing folder directory in windows powershell using the cd command

That's how easy it is to use compact.exe to compress folders on Windows.

Compressing Files and Folders Natively on Windows

When running out of storage space on your Windows computer, you can do many things to create more space without adding a bigger drive or deleting files you might otherwise need later.

With compact.exe, you can compress files with a simple command in Command Prompt or PowerShell. There's even no need to use a third-party compression tool. If you prefer a more graphical way of using compact.exe, you can look into CompactGUI.