How to Delete a Gmail Account Without Losing Your Emails
On this page
If you want to stop using Gmail but keep your messages, save a separate copy before removing Gmail from your Google Account. Deleting Gmail removes the Gmail service and its address; deleting your entire Google Account also affects other Google services. Google documents these as separate actions in its Gmail removal instructions.
mailmd is a free, open-source tool that saves each message as a Markdown file, a plain-text file with simple formatting, on your computer. You can open these files outside Gmail. The safe order is simple: make the copy, check that you can read it, then delete Gmail.
Copy your Gmail with mailmd #
mailmd works well if you want readable message files on your computer instead of another synced mailbox. It uses the Gmail API, Google's interface for software that accesses Gmail. To connect, you need your own OAuth app in Google Cloud. mailmd’s project site and setup instructions explain how to set it up.
On macOS, Linux, or Windows in Git Bash, install mailmd and start connecting your account:
curl -fsSL https://raw.githubusercontent.com/vincentsch/mailmd/main/install.sh | sh
mailmd connect imap --email you@example.com
mailmd syncFor Gmail, follow the setup instructions for the Gmail API and OAuth app. OAuth is a way to authorize access without handing the tool your regular Gmail password. You enter credentials yourself; mailmd requests read access and does not mark messages as read, move or delete mail, or send messages.
The archive goes in ~/mail/<account>. Each email becomes a Markdown file with message details, such as the sender and date, at the top. Attachments are saved next to their messages. Spam and Trash are left out unless requested, so check that your copy includes the mail you need. Gmail messages stored in All Mail include archived mail.
Check the archive before removing Gmail #
Run mailmd sync again shortly before deleting Gmail, then open the archive folder and inspect messages from different dates. Confirm that message bodies appear and open important attachments. Try searching for a known sender or a distinctive phrase, and check the files without relying on an active Gmail connection.
mailmd does not delete files from its archive. If you later delete a message from Gmail, mailmd keeps its local file and marks the message as deleted on the server. You still need to protect the archive: keep a separate backup of the folder if the messages matter to you.
mailmd does not import mail into a replacement inbox or free Gmail storage by itself. If you want your old messages in a new online mailbox, move them there and confirm the migration before deleting Gmail. Google also offers a Gmail data export, which gives you an exported file rather than a browsable mailbox.
Remove Gmail while keeping your Google Account #
Before deleting Gmail, change the email address on important services such as banking, social media, and password recovery. If you need to keep receiving mail sent to your Gmail address, wait to delete it: after removal, that address can no longer send or receive messages.
To remove Gmail, open your Google Account’s Data & privacy settings and choose the option to remove data from services you no longer use. Select the delete control beside Gmail and enter a non-Gmail address. Then use the message Google sends to that address to verify it. Google’s menus use different labels in some places, so follow the current Gmail-specific removal instructions if the wording differs.
Removing Gmail leaves the rest of your Google Account available. Choose the separate account-deletion option only if you also intend to remove other Google services and data.
Free and open source
Try mailmd
mailmd is a free command-line tool that copies your email into Markdown files on your computer, one file per message. It works with any IMAP mailbox, and with Gmail and Outlook through their own APIs.
Install
$ curl -fsSL https://raw.githubusercontent.com/vincentsch/mailmd/main/install.sh | sh
Set it up with your coding agent
Set up mailmd so you can read my email. Use https://github.com/vincentsch/mailmd: read its AGENTS.md and follow the steps. Connect my mailbox and run the first sync. Then show me where the files are.