A powerful local CLI tool to sync, cluster, and surgically clean your Gmail.
Project description
Gmail Cleaner
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 clean
Gmail 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.
Before / after
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.
Setup
The most effort Gmail Cleaner will ever ask of you:
1. Enable the Gmail API
- 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.
2. Set Up Desktop App Credentials
- 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.
3. Install
You can install directly from PyPI or download the standalone .exe from the latest GitHub Release.
pip install gmail-cleaner
Configuration
Before 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.
Commands
| 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.
FAQ
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.
License
MIT. The shortest license that works.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gmail_cleaner-0.1.0.tar.gz.
File metadata
- Download URL: gmail_cleaner-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ca20821d011184a0a44f9e3232f7bb460a1cacf3ab5c5c7afd7020d09795ef0
|
|
| MD5 |
9b5eade405ad76a4d354a2828735f0ab
|
|
| BLAKE2b-256 |
37eb8772c2bb49364af6465339732d004e74bbebf52cad2cc013b20f720f13bd
|
Provenance
The following attestation bundles were made for gmail_cleaner-0.1.0.tar.gz:
Publisher:
release.yml on immkg/gmail-cleaner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmail_cleaner-0.1.0.tar.gz -
Subject digest:
6ca20821d011184a0a44f9e3232f7bb460a1cacf3ab5c5c7afd7020d09795ef0 - Sigstore transparency entry: 1886675190
- Sigstore integration time:
-
Permalink:
immkg/gmail-cleaner@adb1b6a7e2a602bd195992d4d298a783d059e1b9 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/immkg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@adb1b6a7e2a602bd195992d4d298a783d059e1b9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gmail_cleaner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gmail_cleaner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
518dbbcd7257f7bd06a8d9b13e76904aa0d33d62281453d9714bbda8d07ed5be
|
|
| MD5 |
4db27438c2226d17ac41ce9ec380bf05
|
|
| BLAKE2b-256 |
ebd5ec32c517f4662e31c22ec66254d44662dca0fbd1e3fec7619fc8720d119f
|
Provenance
The following attestation bundles were made for gmail_cleaner-0.1.0-py3-none-any.whl:
Publisher:
release.yml on immkg/gmail-cleaner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmail_cleaner-0.1.0-py3-none-any.whl -
Subject digest:
518dbbcd7257f7bd06a8d9b13e76904aa0d33d62281453d9714bbda8d07ed5be - Sigstore transparency entry: 1886675193
- Sigstore integration time:
-
Permalink:
immkg/gmail-cleaner@adb1b6a7e2a602bd195992d4d298a783d059e1b9 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/immkg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@adb1b6a7e2a602bd195992d4d298a783d059e1b9 -
Trigger Event:
push
-
Statement type: