How to clear the Hugging Face cache

Every from_pretrained() and load_dataset() call caches files on disk, and large models make that folder grow fast. The hf CLI can list and delete per model, which is gentler than wiping the folder.

These commands permanently delete files. Most are caches the tool rebuilds on its own (the next build or install is slower and may need internet). Anything that can hold data you cannot re-download is flagged on the page. Read each command, then copy and run it yourself. devdisk never runs cleanup commands for you.

Where it lives

HF_HOME or HF_HUB_CACHE override these.

List what is cached

Any OS (huggingface_hub 1.0+)
pip install -U huggingface_hub
hf cache ls
hf cache ls --revisions
Older huggingface_hub
huggingface-cli scan-cache

Delete models or old revisions

Any OS (huggingface_hub 1.0+)
hf cache rm model/bert-base-uncased --dry-run
hf cache rm model/bert-base-uncased
hf cache prune --dry-run   # detached revisions + unfinished downloads
hf cache prune
Older huggingface_hub
huggingface-cli delete-cache   # interactive picker

Run with --dry-run first to see exactly what goes.

Windows note

Without Developer Mode (or admin rights) the cache cannot use symlinks, so files are duplicated and the cache uses more space than on macOS or Linux.

Measure with devdisk

devdisk is a free, read-only scanner. It lists ~/.cache/huggingface under Review first (AI models), since re-downloading big models is slow. It never deletes anything; it only shows sizes and writes a cleanup script you read and run yourself.

macOS / Linux
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
Windows (PowerShell)
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py

Run free scannerSample report

Want one-click cleanup?

A planned devdisk desktop app for Mac and Windows: live treemap, cleanup that moves files to the Trash, scheduled scans. One email when it launches, with an early-supporter price. Your address is used only for that, and every email has an unsubscribe link.

FAQ

Is it safe to delete the whole huggingface folder?

Nothing breaks, but every model and dataset downloads again on next use, and saved tokens under HF_HOME may need a new login.

What does hf cache prune remove?

Revisions no longer referenced by a branch or tag, plus leftover files from interrupted downloads.

Does devdisk delete models?

No. It only reports sizes.

More cleanup guides