Skip to main content

A powerful local CLI tool to sync, cluster, and surgically clean your Gmail.

Project description

Gmail Cleaner Logo

Gmail Cleaner

Because somewhere in those 50,000 emails is a tax document you actually need.

PyPI version Coverage Release MIT license

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

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Navigate to APIs & Services > Library.
  4. Search for "Gmail API" and click Enable.

2. Set Up Desktop App Credentials

  1. Go to APIs & Services > OAuth consent screen. Choose External and add your own Gmail address under Test users.
  2. Go to APIs & Services > Credentials.
  3. Click Create Credentials > OAuth client ID.
  4. Choose Desktop app.
  5. Click Download JSON on the confirmation dialog.
  6. Rename the file to credentials.json and 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmail_cleaner-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gmail_cleaner-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

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

Hashes for gmail_cleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ca20821d011184a0a44f9e3232f7bb460a1cacf3ab5c5c7afd7020d09795ef0
MD5 9b5eade405ad76a4d354a2828735f0ab
BLAKE2b-256 37eb8772c2bb49364af6465339732d004e74bbebf52cad2cc013b20f720f13bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmail_cleaner-0.1.0.tar.gz:

Publisher: release.yml on immkg/gmail-cleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for gmail_cleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 518dbbcd7257f7bd06a8d9b13e76904aa0d33d62281453d9714bbda8d07ed5be
MD5 4db27438c2226d17ac41ce9ec380bf05
BLAKE2b-256 ebd5ec32c517f4662e31c22ec66254d44662dca0fbd1e3fec7619fc8720d119f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmail_cleaner-0.1.0-py3-none-any.whl:

Publisher: release.yml on immkg/gmail-cleaner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page