Automatically Archive Your Read E-mails in Gmail

Automatically Archive Your Read E-mails in Gmail

Updated August 13, 2021

Email is still a normal part of life, we use it in our professional and personal lives. It accumulates if one is not careful. One day your mailbox has a couple of new messages and a couple of hundred old messages. The next day, you have thousands of already read messages that ‘feel’ like they are cluttering up your inbox.

Today one has many options for email services, but the most popular by a large margin is Gmail. It was reported as of August 2021 that there were over 1.8 billion users of the platform worldwide. That is more than three times the amount of its closest competitor Outlook, so this tool will be something that can be used by all Gmail users who like to keep a tidy Inbox.

The problem: How to keep my inbox clean of messages I have already read?

Solution #1 (easiest and most manual):

As you read the message either trash or archive it. To do this, you need to click one of the buttons on the message menu above the message itself.

gmail01.png Click the archive button (in the picture above — the button inside the purple circle) to archive the message. Or if you are comfortable getting rid of the message entirely click the trash button (inside red circle).

One of the major drawbacks to this solution (at least to me) is that one can’t smoothly go from one new message to the next (Google may have fixed this by the time you read this). Each time you click one of the above icons, you are returned to your inbox list of messages. If you have more than fifty (50) messages, you may have to go back to the last new message to read the oldest new message first.

Solution #2:

Wouldn’t it be wonderful if Gmail were to look at the Inbox periodically and see if any messages that have already been read have been in the Inbox for longer than 1 day (24 hours) providing one up to 24 hours to act on the message before it archives it and removes it from the Inbox? Now here’s where the AutoArchiver comes in.

As I searched the internet for a solution (because I have learned that even my most brilliant ideas someone has thought of before), I found several methods but none were what I wanted. Then I came across an article by fwed titled “ Auto archive emails in Gmail after 2 days ”. The article essentially walked the reader through the process of setting up a script that would take messages labeled with the tag ‘autoarchive’ and have a script archive them after two days.

I grabbed their script and forked it to make a version that better suited what I wanted to do. The script as it was, required that each message one wanted to archive be labeled with a unique archive tag. It would then archive the message if more than 48 hours had passed. I was looking for something a tad different.

After a couple of changes to the script, I deployed it on my Gmail account. So far it has been working with little to no issues since I put it in place back in 2018. Also, my Inbox has never been cleaner.

How to use the script in your Gmail account:

Here is how to add the script to your Gmail account. Essentially you are copying the script and deploying it to your account.


  1. Copy the script from GitHub .
  2. Go to
  3. Click the ‘+ New Script’ link on the top left of the page.
  4. In the new window, highlight all the text in the script window and paste the script in its place.
  5. Click File > Save
  6. Name it gmailAutoArchiver (or whatever you like).
  7. Click on the Run icon.
  8. Go through the approval screens allowing the script access to your Gmail account so it can process the messages.
  9. Click Edit > All your triggers
  10. Click the ‘Add a new trigger’ link at the bottom of the screen. The new trigger should look like this: gmail02.png
  11. Click the Save button and you are all set.

Now you can enjoy your clean inbox as much as I am enjoying mine! If you make improvements please do share.

Article originally published on medium