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
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:
The output lists compression information for files under that path. Running
The options mean:
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.
Wildcards supported by
Use selective compression when the folder also contains formats such as videos, ZIP archives, virtual disks, or other data unlikely to shrink.
The
Compressed files should be reported as compressed, and the summary should show a compression ratio. A ratio close to
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.
Windows reports whether the system is currently in the Compact state and may indicate whether compression is beneficial for that installation.
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.
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.
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.
If the ratio is near
If it still fails, leave that file uncompressed rather than repeatedly forcing it.
Then confirm with:
Use targeted compression for cold or mostly read-only data instead of compressing every folder on a drive.
If Windows remains usable but the operation repeatedly fails, do not apply generic compression to
The
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.
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.
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.
- Open File Explorer.
- Select This PC.
- Right-click the drive containing the target folder and select Properties.
- On the General tab, confirm that File system is NTFS.
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
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.
- Open File Explorer.
- 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. - Record the folder’s current disk usage:
- Right-click the folder and select Properties.
- On the General tab, note both:
- Size
- Size on disk
- Select Advanced on the General tab.
- Select Compress contents to save disk space.
- Select OK, and then select Apply.
- 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. - Select OK.
- 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.
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:- Right-click Start.
- Select Terminal or Windows Terminal.
- Right-click Start.
- Select Terminal (Admin) or Windows Terminal (Admin).
- Approve the User Account Control prompt.
2. Query the folder before changing it
ReplaceD:\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
Run:Warning: Verify the path carefully before pressing Enter. The/soption processes all subdirectories below the specified location. Do not substituteC:\,C:\Windows, or another broad system path unless you have a tested recovery plan.
compact /c /s:"D:\Archive" /iThe options mean:
/ccompresses the specified files and marks directories for compression./s:"D:\Archive"includes the folder and its subdirectories./icontinues when an individual file produces an error instead of stopping the entire operation.
/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 /iWildcards 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
- Right-click the compressed folder and select Properties.
- Compare the new Size on disk value with the value recorded before compression.
- Select Advanced and confirm that Compress contents to save disk space remains selected.
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:- Open File Explorer.
- Select This PC.
- Review the free-space value under Devices and drives.
- Windows 11: Start > Settings > System > Storage
- Windows 10: Start > Settings > System > Storage
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.
- Right-click Start and select Terminal (Admin) or Windows Terminal (Admin).
- Approve the User Account Control prompt.
- Check the current Compact OS state:
compact /compactos:queryWindows reports whether the system is currently in the Compact state and may indicate whether compression is beneficial for that installation.
- To enable Compact OS, run:
compact /compactos:always- Leave the window open until the command reports that the operation completed.
- Query the state again:
compact /compactos:queryThe 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.
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:queryIf 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:- Right-click the folder and select Properties.
- Select Advanced.
- Clear Compress contents to save disk space.
- Select OK, and then Apply.
- Select Apply changes to this folder, subfolders and files.
- Select OK and wait for decompression to finish.
compact.exe, run:compact /u /s:"D:\Archive" /iThe
/u option decompresses NTFS-compressed files and marks the directories so newly added files are not automatically compressed.Verify rollback with: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.
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.
- Open Terminal (Admin).
- Run:
compact /compactos:never- Wait until Windows reports that decompression completed.
- Verify the result:
compact /compactos:queryThe 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.