A simple CLI tool to bulk delete emails from your Gmail inbox. Find your top email senders and delete them in one go.
- Scan subscription emails (newsletters, promotions)
- Scan unread emails
- View top 20 senders by email count
- Bulk delete emails by sender
- Allowlist domains you want to keep
- Deletion history log
- Go to Google Cloud Console
- Click Select a project → New Project
- Name it (e.g., "Gmail Cleaner") and click Create
- In your project, go to APIs & Services → Library
- Search for "Gmail API"
- Click Gmail API → Enable
- Go to APIs & Services → OAuth consent screen
- Select External → Create
- Fill in required fields:
- App name:
Gmail Cleaner - User support email: your email
- Developer contact: your email
- App name:
- Click Save and Continue
- On Scopes page, click Save and Continue (no changes needed)
- On Test users page:
- Click Add Users
- Add your Gmail address
- Click Save and Continue
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Application type: Desktop app
- Name:
Gmail Cleaner - Click Create
- Click Download JSON
- Rename the file to
credentials.jsonand move it to this folder
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtpython gmail_cleaner.pyOn first run, a browser window will open for Google authentication. Sign in and click Continue (you may see a warning about unverified app - this is normal for personal projects).
python gmail_cleaner.pyGmail Cleaner
What do you want to scan?
1 - Top subscription emailers
2 - Most unread emails
q - Quit
> 1
Scanning top 1000 subscription emails...
Processed 1000/1000...
Top 20 subscription senders:
# Sender Emails
--------------------------------------------------
1 Newsletter Daily 234
2 LinkedIn 189
3 Medium 145
...
Commands:
1,3,5 - Delete emails from these senders
all - Delete all listed
keep 2,4 - Add to allowlist (won't show again)
r - Rescan (choose type)
q - Quit
> 1,3
Delete from: newsletter.com, medium.com? (y/n): y
Deleting from newsletter.com... 234 emails trashed
Deleting from medium.com... 145 emails trashed
Moved 379 emails to trash.
Delete all emails from a specific sender:
python gmail_cleaner.py [email protected]
python gmail_cleaner.py linkedin.com| File | Description |
|---|---|
credentials.json |
Your Google OAuth credentials (DO NOT SHARE) |
token.pickle |
Saved auth token (DO NOT SHARE) |
allowlist.txt |
Domains to skip when scanning |
deleted_log.txt |
History of deleted emails |
credentials.jsonandtoken.picklecontain sensitive data - never commit them- The tool only moves emails to Trash (recoverable for 30 days)
- You can revoke access anytime at Google Account Permissions
MIT