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.
Where it lives
- macOS / Linux:
~/.cache/huggingface/hub(models),~/.cache/huggingface/datasets(processed datasets) - Windows:
C:\Users\<you>\.cache\huggingface\hub
HF_HOME or HF_HUB_CACHE override these.
List what is cached
pip install -U huggingface_hub hf cache ls hf cache ls --revisions
huggingface-cli scan-cache
Delete models or old revisions
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
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.
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py
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.