Because somewhere in those 50,000 emails is a tax document you actually need.
Built by Mayank Gupta
Surgical precision for your inbox. ~99% less clutter · ~100% more sanity · 100% local.
You have 50,000 emails. Somewhere in that mountain of newsletters, random promotions, and auto-generated alerts is a critical message from your bank that you cannot afford to lose. You can't just 'Select All -> Delete'.
You need a surgical tool.
With Gmail Cleaner:
# It just deletes them.
python -m gmail_cleaner.main cleanGmail Cleaner synchronizes your Gmail account into a local SQLite database, analyzes your emails using Pandas and Scikit-Learn, and interactively bulk-deletes the noise based on aggressive, local strategies.
You try to find an important bank email. Your search results are flooded with 400 "Limited Time Offer!" emails from a newsletter you never subscribed to.
After Gmail Cleaner: You actually see your bank email.
The most effort Gmail Cleaner will ever ask of you:
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to APIs & Services > Library.
- Search for "Gmail API" and click Enable.
- Go to APIs & Services > OAuth consent screen. Choose External and add your own Gmail address under Test users.
- Go to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Choose Desktop app.
- Click Download JSON on the confirmation dialog.
- Rename the file to
credentials.jsonand place it in the root folder.
You can install directly from PyPI or download the standalone .exe from the latest GitHub Release.
pip install gmail-cleanerBefore running the clean command, open gmail_cleaner/config.py and customize your patterns:
AUTO_DELETE_EMAIL_PATTERNS: Add email addresses or domains that you always want to delete instantly (e.g.newsletter@spam.com).PROTECTED_EMAIL_PATTERNS: Add personal or banking emails that should NEVER be deleted by the tool (e.g.@yourbank.com).
Lazy, not negligent: The code ensures these patterns are scrubbed from version control, so you can safely keep this repo synced without leaking your personal contacts.
| Command | What it does |
|---|---|
python -m gmail_cleaner.main sync |
Syncs your emails to a local SQLite database. |
python -m gmail_cleaner.main analyze |
Analyzes emails to show top domains, senders, and TF-IDF topic clusters. |
python -m gmail_cleaner.main clean |
Starts the interactive CLI to bulk delete emails based on strategies (newsletters, promotions, etc.). |
python -m gmail_cleaner.main clean --dry-run |
Simulates the deletion queue and prints what would be deleted without touching the Gmail API. |
When cleaning, you can select specific email ranges (e.g., 1,2,5-10, k10 to keep the latest 10) and accumulate deletions before executing them in bulk by typing yes to skip or now to process the queue.
Does it upload my emails to a random server?
No. It downloads them to a local SQLite database (gmail.db). The TF-IDF analysis, clustering, and deleting all happen entirely on your machine. 100% local.
Will it accidentally delete my tax returns or bank statements?
Not if you tell it not to. Add @yourbank.com or your accountant's email to PROTECTED_EMAIL_PATTERNS in config.py. Once there, it becomes structurally impossible for the tool to delete them, even if you explicitly select them.
Can I undo a deletion? Yes. The tool moves emails to the Gmail Trash folder; it doesn't permanently annihilate them. You have 30 days to rescue them through the standard Gmail UI before Google purges them forever.
What if I really need that shoe store newsletter from 2019?
You don't. Insist anyway and you can use the k command (e.g., k10) to keep the latest 10 and delete the rest. But it will judge you silently.
MIT. The shortest license that works.
