Free Disk Space with NTFS Compression and compact.exe in Windows 10/11

NTFS compression can free disk space without deleting files by storing selected files and folders in compressed form and decompressing them automatically when applications access them. Use folder-level NTFS compression for documents, source code, logs, and other compressible data; use compact.exe when you need recursive processing, scripting, verification, or Compact OS. These methods are supported in Windows 10 and Windows 11 on NTFS-formatted volumes.

Prerequisites and compatibility​

Before compressing anything:
  • Back up irreplaceable files.
  • Confirm that the destination volume uses NTFS.
  • Close applications that are actively using files in the target folder.
  • Keep some free space available while Windows rewrites the files.
  • Use an administrator account when processing protected locations or enabling Compact OS.
  • Connect a laptop to AC power and do not interrupt a large compression or decompression operation.
To confirm the file system:
  1. Open File Explorer.
  2. Select This PC.
  3. Right-click the drive containing the target folder and select Properties.
  4. On the General tab, confirm that File system is NTFS.
NTFS compression is not available on FAT32 volumes. It is transparent and lossless: applications normally open compressed files as usual, and the original data is restored exactly when read.
Compression works best on text files, Office documents, logs, source code, uncompressed images, and similar data containing repetition. It usually saves little space on files already compressed internally, including:
  • JPEG, PNG, MP3, AAC, and most video files
  • ZIP, 7Z, RAR, CAB, and ISO files
  • Many installer packages
  • Some game assets and application packages
Avoid routinely compressing virtual-machine disks, database files, mail stores, heavily used game libraries, or other large files that are constantly being modified. These workloads may gain little space while increasing processor and storage activity. Microsoft also notes that NTFS compression may fail for an individual file larger than 30 GB.

Method 1: Compress a folder through File Explorer​

This is the safest method for a normal data folder because you can select exactly what Windows should compress.
Warning: Do not begin by compressing the entire Windows installation, the root of drive C, or application folders. Test a noncritical data folder first. A full-drive operation can take a long time, encounter locked files, and affect performance. Use Compact OS rather than generic recursive NTFS compression if the goal is specifically to compress Windows system binaries.
  1. Open File Explorer.
  2. Locate the folder to compress.
    Good initial candidates include archive folders, old project folders, exported logs, document collections, and data that is read more often than it is changed.
  3. Record the folder’s current disk usage:
    1. Right-click the folder and select Properties.
    2. On the General tab, note both:
      • Size
      • Size on disk
    Size is the logical amount of data. Size on disk is the storage currently allocated on the volume and is the value expected to decrease after successful compression.
  4. Select Advanced on the General tab.
  5. Select Compress contents to save disk space.
  6. Select OK, and then select Apply.
  7. When Windows displays Confirm Attribute Changes, select:
    Apply changes to this folder, subfolders and files
    This choice compresses existing contents and sets the folder so that newly created files and subfolders normally inherit its compression attribute.
  8. Select OK.
  9. Wait for the operation to finish.
    Windows may display a progress dialog for a large folder. If a permissions or file-in-use prompt appears, note the affected path before choosing Ignore, Ignore All, or Continue.
No restart is required. Files can be opened normally after the operation completes.

Method 2: Compress a folder with compact.exe​

compact.exe is the command-line version of NTFS compression. It is useful for large directory trees, repeatable maintenance, wildcard selection, and detailed reporting.

1. Open a command window​

For a folder owned by your account:
  1. Right-click Start.
  2. Select Terminal or Windows Terminal.
For protected folders or folders owned by another account:
  1. Right-click Start.
  2. Select Terminal (Admin) or Windows Terminal (Admin).
  3. Approve the User Account Control prompt.
Command Prompt can also be used. The command syntax is the same.

2. Query the folder before changing it​

Replace D:\Archive with the actual path:
compact /s:"D:\Archive"
The output lists compression information for files under that path. Running compact without parameters reports the compression state of the current directory and its files.

3. Compress the folder and all existing contents​

Warning: Verify the path carefully before pressing Enter. The /s option processes all subdirectories below the specified location. Do not substitute C:\, C:\Windows, or another broad system path unless you have a tested recovery plan.
Run:
compact /c /s:"D:\Archive" /i
The options mean:
  • /c compresses the specified files and marks directories for compression.
  • /s:"D:\Archive" includes the folder and its subdirectories.
  • /i continues when an individual file produces an error instead of stopping the entire operation.
Do not add /q during the first run. Without /q, the command provides more useful progress and summary information.
Expected results include file-processing messages followed by a summary showing how many files were processed and the resulting compression ratio. Files that are locked, unsupported, already compressed, or inaccessible may be skipped.

4. Compress only selected file types when appropriate​

For example, to compress .log files under a log archive without broadly targeting every file type:
compact /c /s:"D:\LogArchive" *.log /i
Wildcards supported by compact.exe include * and ?.
Use selective compression when the folder also contains formats such as videos, ZIP archives, virtual disks, or other data unlikely to shrink.

5. Force a file to be recompressed after interruption​

If compression was interrupted by a crash or loss of power, force Windows to process a specific file again:
compact /c /f "D:\Archive\example.dat"
The /f option forces compression even when Windows would otherwise treat the file as already compressed. It should not be added routinely to every operation because it can unnecessarily rewrite files.

Verify that disk space was recovered​

Use at least two of the following checks.

Check the folder’s allocated size​

  1. Right-click the compressed folder and select Properties.
  2. Compare the new Size on disk value with the value recorded before compression.
  3. Select Advanced and confirm that Compress contents to save disk space remains selected.
A mixed folder can display an indeterminate or partially selected state if some files were skipped or have different attributes.

Query with compact.exe​

Run:
compact /s:"D:\Archive"
Compressed files should be reported as compressed, and the summary should show a compression ratio. A ratio close to 1.0 to 1 indicates that the data did not compress effectively.

Check total drive space​

Both Windows versions show drive capacity in File Explorer:
  1. Open File Explorer.
  2. Select This PC.
  3. Review the free-space value under Devices and drives.
The Storage settings path is also the same in both versions:
  • Windows 11: Start > Settings > System > Storage
  • Windows 10: Start > Settings > System > Storage
The displayed free-space total may not refresh immediately. Close and reopen File Explorer or wait for Windows to recalculate storage usage.

Alternate method: Enable Compact OS​

Compact OS compresses Windows operating-system binaries using a mechanism designed for system files. It is supported in Windows 10 and Windows 11 on both UEFI-based and BIOS-based devices.
Use this only when the Windows drive is short on space and ordinary cleanup or targeted folder compression is insufficient. It is different from running recursive NTFS compression against the whole C drive.
Warning: Enabling or disabling Compact OS rewrites many operating-system files and may take several minutes. Connect the computer to reliable power, close running applications, suspend heavy disk activity, and ensure that important data is backed up. Do not terminate the command or force the computer off while it is working. Decompression also requires enough available disk space to restore the uncompressed binaries.
  1. Right-click Start and select Terminal (Admin) or Windows Terminal (Admin).
  2. Approve the User Account Control prompt.
  3. Check the current Compact OS state:
compact /compactos:query
Windows reports whether the system is currently in the Compact state and may indicate whether compression is beneficial for that installation.
  1. To enable Compact OS, run:
compact /compactos:always
  1. Leave the window open until the command reports that the operation completed.
  2. Query the state again:
compact /compactos:query
The expected result is a message confirming that the system is in the Compact state.
A restart is not normally required after the command completes, but restarting once is reasonable before evaluating performance and final free space.

Troubleshooting​

“The file system does not support compression”​

The target volume is normally FAT32, exFAT, or another file system without NTFS per-file compression.
Check This PC > drive Properties > General > File system. Move the files to an NTFS volume or convert/reformat the destination using an appropriate backup and migration process. Do not format a drive containing needed data merely to enable compression.

“Access is denied” or files are skipped​

Close applications using the folder and rerun the command from Terminal (Admin). Also verify that your account has permission to modify the affected files.
System-protected files, files owned by another account, security-software data, and currently open application files may remain uncompressed. Review the reported paths rather than repeatedly forcing the operation.

Compression finishes but almost no space is recovered​

The folder probably contains data already compressed internally. Run:
compact /s:"D:\Archive"
If the ratio is near 1.0 to 1, decompress the folder and target a more suitable data set. Videos, photos, archives, installers, and many game files usually offer poor results.

Some files compress but others do not​

Possible causes include:
  • The file is open or locked.
  • Permissions prevent modification.
  • The file is too large for successful NTFS compression.
  • The file is encrypted or uses an incompatible storage attribute.
  • The operation was interrupted.
  • The application rewrote or replaced the file after compression.
Close the associated application and process the individual file again:
compact /c /f "D:\Archive\problem-file.dat"
If it still fails, leave that file uncompressed rather than repeatedly forcing it.

New files are not compressed​

Compressing existing files does not always mean that the parent directory was marked for inheritance. Apply compression to the folder itself through Properties > Advanced, choosing Apply changes to this folder, subfolders and files, or run:
compact /c "D:\Archive"
Then confirm with:
compact "D:\Archive"

Performance becomes worse​

Compression uses processor time when files are read or written. Decompress folders containing databases, virtual disks, build-output directories, heavily modified project data, or latency-sensitive applications.
Use targeted compression for cold or mostly read-only data instead of compressing every folder on a drive.

Compact OS reports an error or stops unexpectedly​

Confirm that Terminal is running as administrator, connect the system to power, restart Windows, and retry after closing applications. Run the state query first:
compact /compactos:query
If Windows remains usable but the operation repeatedly fails, do not apply generic compression to C:\Windows as a substitute. Use Windows Storage cleanup to create additional working space and then retry Compact OS.

Roll back NTFS compression​

To decompress through File Explorer:
  1. Right-click the folder and select Properties.
  2. Select Advanced.
  3. Clear Compress contents to save disk space.
  4. Select OK, and then Apply.
  5. Select Apply changes to this folder, subfolders and files.
  6. Select OK and wait for decompression to finish.
To decompress recursively with compact.exe, run:
compact /u /s:"D:\Archive" /i
The /u option decompresses NTFS-compressed files and marks the directories so newly added files are not automatically compressed.
Warning: Decompression increases disk usage. Confirm that the drive has enough free space before starting. If space is critically low, decompress smaller subfolders individually or move data to another drive first.
Verify rollback with:
compact /s:"D:\Archive"
The files should be reported as uncompressed, and the folder’s Properties > Advanced dialog should no longer have Compress contents to save disk space selected.

Disable Compact OS​

Warning: Disabling Compact OS expands Windows binaries and requires additional free disk space. Do not run this command when the system drive is nearly full. Free space or connect external storage before proceeding.
  1. Open Terminal (Admin).
  2. Run:
compact /compactos:never
  1. Wait until Windows reports that decompression completed.
  2. Verify the result:
compact /compactos:query
The final query should report that the system is not in the Compact state. If decompression cannot complete because of insufficient space, free additional storage through Settings > System > Storage, restart Windows, and rerun the disable command.
 

Back
Top