I want to be able to export Gmail messages as text or HTML files so that they can be stored, passed around, and easily viewed later.

I would really like to be able to locate a selection of my messages (for example, by tag, by sender, etc.) and export them all at once.

Is there a way to do this?

  • Here's a link to a post by Matt Cutts on a related topic from a couple of years back. Commented Jul 8, 2010 at 5:03

15 Answers 15


The key is configuring your account to be accessible via IMAP.

I've used IMAPSize to backup GMail accounts. To schedule regular backups on a server I use OfflineIMAP.

Although a quick G search reveals tons of tools/scripts/services to do backup of IMAP servers and especially of GMail.

  • 1
    I really like the flexibility built into IMAPSize. Thanks for the link.
    – Prestaul
    Commented Jul 12, 2010 at 15:16
  • 3
    be aware IMAP is not good for backups as it syncs both sides, so you delete from one side, it propagates to the other.
    – cregox
    Commented Oct 5, 2010 at 0:53
  • 2
    @Cawas You don't delete when creating a backup.
    – Vinko Vrsalovic
    Commented Oct 5, 2010 at 6:10
  • 2
    My bad, Vinko. I was just trying to give a general warning for everyone and @Prestaul. Didn't actually read you were talking about backup - I just assumed the subject was about exporting. Yes, if you backup the IMAP, then you have a backup. I meant IMAP on itself may seem like a backup, but it's not.
    – cregox
    Commented Oct 5, 2010 at 15:45
  • what is the server setting when I am adding a gmail account. Is it www.gmail.com ? Commented Aug 8, 2012 at 6:48

A Google engineering team started an internal 'organization' dedicated to this called the Data Liberation Front. They are working through all the Google products and will continue to update their site as new or improved methods for moving data in and out of their web applications are created.

The DLF sees themselves as being a bit subversive, because a company doesn't usually make it easier for their customers to leave. You can read about how they started and why on their FAQ

  • 24
    The DLF is actually Google... just FYI :)
    – Nic Wise
    Commented Oct 9, 2010 at 21:30
  • 3
    Few companies make it as easy for the customer to get his/her data as Google does.
    – Suzana
    Commented Mar 6, 2013 at 23:45
  • This is incredibly easy. Great answer. Commented Jan 11, 2017 at 7:05

Similar to @LBushkin's suggestion, use a local POP client, but use Thunderbird. Outlook uses a proprietary format for its local data store.

Emails are saved as plain text files, one file per folder.

  • 6
    This is the right answer, except use IMAP so you can pull out all the messages with a specific tag (tags will appear as folders under the [Gmail] folder). Also, if you have a lot of email, turn on the "Advanced IMAP Controls" Labs feature, then, under "Manage Labels", turn off IMAP access for all the folders except the one you want to download.
    – Matt
    Commented Jul 7, 2010 at 19:56

Consider got-your-back which "is a command line tool that backs up and restores your Gmail account".

You can invoke it like this:

python gyb.py --email [email protected] --search "from:[email protected]" --local-folder "mail_from_pip"

After completion you'll find all the emails matching the --search in the specified --local-folder, along with a sqlite database.

  • 1
    Awesome! Thanks! For windows users: the command is simply gyb --email [email protected] --search "from:[email protected]" --folder "mail_from_pip"
    – Jules
    Commented May 21, 2013 at 11:51
  • holy molé that is slick... BAM! got my emails Commented Apr 15, 2014 at 2:07

Gmail has just rolled out a feature allowing users to back up their emails: https://www.google.com/settings/takeout :

enter image description here

Old UI:

enter image description here

  • This works reasonably well. However, the mbox files can be very large - like 5 GB. If you have a slow connection it may time out.
    – bgmCoder
    Commented Sep 6, 2016 at 21:00

In Google Labs enable create a document, then go back to the thread you want to export as a document and click 'create a document'.

then in Google documents you can save the resulting document as HTML (zipped) or your can download it as plain text amongst a number of other formats.

  • shame... code.google.com/labs says: "the Google Code Labs program has been retired. APIs that were part of Code Labs have graduated or have been deprecated."
    – Augusto
    Commented Mar 30, 2015 at 16:38

The easiest way may be to use a local POP client like Outlook to download them. Then you can easily export or save them to text.

For an individual email, you could use Print to print the contents to a file on your machine... but that would get painful quickly for more than a few emails.

  • I use Entourage (the Mac version of Outlook), but I don't see a way to export to text or html there either. It will only allow me to export to an "archive"...
    – Prestaul
    Commented Jun 30, 2010 at 23:21

I have had success using IMAP Tools to backup other (non-Gmail) IMAP accounts. I used both imapdump.pl and IMAPToMbox.pl; they generate one text file per email or one text file per folder, respectively. Both commands allow specifying which IMAP folders (Gmail's tags) you want to back up.

This method suits me well, 'cause I can backup my account automatically (say, a cron job) without my intervention.


I access Gmail with a mail client which stores email in the maildir format. Maildir simply stores each email in its original RFC822 message format in a separate file. These are readable text files, although modern email is often cluttered with base64 encoded mail attachments.

There are multiple gnu/linux email clients which support maildir, including Evolution which is the standard mail client in the Ubuntu distribution. However, there are no Windows email clients supporting maildir that I know of.


I am one of the authors of BackupGoo. We also wanted to have a secure offline copy of our data. BackupGoo is really simple to use and backups all your stuff from Google to your local harddrive in widely-used formats. This includes e.g. GMail, Google Docs, Google Reader. GMail for instance is saved as plain text "Mime-Message" that can be viewed in any text editor or offline email client.

  • Do you mean you back up gmail folders in unix mbox format? Might that be very redundant since a given email message may have several labels in gmail? (Perhaps it's not a big deal though.)
    – dreeves
    Commented Oct 6, 2010 at 16:19

Import the set of email messages that you want to export in Mozilla Thunderbird by establishing a IMAP link. Install the ImportExportTools add-on and use it to export the messages locally to HTML or EML. The add-on will create a single file for each message as well as an HTML index page that makes it easier to locate specific emails.


Gmail Keeper does exactly this - it downloads emails from Gmail (via IMAP) and stores them in standard eml format (zipped).

Disclaimer: I wrote this Windows (only) tool, as I couldn't find a suitable one, years ago, when I started felling I should backup my Gmail.

  • not free either
    – mplungjan
    Commented Jun 6, 2012 at 14:03

If you just want your email addresses out in a list, I used Gmail email extractor ("GME").

It is not a free product and can be purchased on http://starbanana.com/ (I am not affiliated with them)

It worked for me using my Google Apps account so thought it might help you out.


backupify.com allows you to export in mbox or json - oh, and it also backs-up your email!

  • 15 day trial - 3USD per user after
    – mplungjan
    Commented Jun 6, 2012 at 14:02

Best way to save one email , (if its an html mail which is informative and you want to save it for future reference this method works like a charm) , Just open the gmail inbox and beside top right corner you have 2 signs "Printer" and "In new window" (just on the right side of email subject small icons )

  1. Click on "in new window" this will open the mail as a seperate webpage , Now you can either print it or you can save the whole page as picture using a firefox addon (works for IE and Crome also) "Fireshot" , download and install it and press Ctrl+Atl+Shift+Z to save the whole page as an image / pdf

  2. press Ctrl A and select the whole page , Paste the content in either Microsoft Front page or any html editor and save it as a web page. (or paste it in Notepad++ to save it as text)


  • 1
    OP has stated, multiple times, that just saving a single message is not the goal here.
    – ale
    Commented Sep 4, 2012 at 12:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.