How to Change the Order of Your Gmail Filters

by Michael on February 16, 2010 · 15 comments

Wow. Just minutes after expressing my frustrations about being unable to control the order of Gmail filters, I figured out a simple workaround. As it turns out, Gmail Labs has a “Filter import/export” function that makes it all possible.


For context, e-mail filters can be a great tool for sorting incoming messages. The good news for Gmail users is that Google introduced filters (via Gmail Labs) awhile back, and last summer they took the filtering functionality out of beta.

Unfortunately, there’s no way to control the order in which your filters are applied. Rather, they appear in the list in the order in which they were created. If you’re an e-mail filtering ninja, however, you’re likely aware that the order in which filters are applied often matters.

Until now, the only solution I could come up with was to delete and re-create filters whenever I created a new filter that needed to be higher up in the list. But now there is a better way…

Changing the order of your Gmail filters

This isn’t a pretty solution, but it’s quite easy to implement. Start by going into Gmail Labs (Settings/Labs or click the little green beaker in the top right corner of the Gmail page) and enabling the “Filter import/export” functionality. Be sure to save your changes.

Now when you view your filters (Settings/Filters), there will be a checkbox off to the left of each filter. Simply do the following:

  1. Check the box for all of your filters (or click the “All” link at the bottom)
  2. Scroll down to the “Export” button (which is greyed out unless filter are selected)
  3. Click the button and you’ll be able to save a file called mailFilters.xml

Now simply open up that file in your favorite text or xml editor and modify it to your heart’s content. The filters themselves are wrapped in “entry” tags, like this:

<entry>
blah blah blah (including category, title, id, updated, etc. fields)
</entry>

Just move those blocks around to change the order of the filters.

The last step is to re-import your filters.

  1. Delete your old filters by checking the box next to each and clicking the “Delete” button (next to “Export“)
  2. Click the “Import filters” link at the very bottom of the filters page
  3. Click the “Choose File” button, and select your modified mailFilters.xml file
  4. Click “Open file” and you’ll be presented with a list of filters to import
  5. Make sure all of the checkboxes are checked and then click “Create filters

Note that this same procedure work for Google Apps.


{ 15 comments… read them below or add one }

Matt D February 24, 2010 at 9:26 am

Thanks for posting this! It’s kind of ridiculous that Google still hasn’t implemented a simple way to change the precedence of their filters, but this workaround is great.

Reply

Jordan February 25, 2010 at 7:57 pm

Another alternative is to quickly send items to the bottom of the list by editing them and saving with no changes. That said — it appears that in my filters, they’re getting applied in reverse order. The first filter shown is the last processed.

Is that consistent with others experience as well?

Reply

Graeme March 26, 2010 at 7:20 am

Jammer, thanks for a great solution.
Jordan, I tried your edit/save and the saved one kept its place in the sequence.

Reply

Ted Wood September 16, 2010 at 2:17 pm

I’m a huge advocate of Google apps, but some of the decisions they make around what gets priority and what gets fixed really boggles my mind. I need to control the order of Google filters and I don’t want to have to run through this many-step process just to control that. Please fix this Google!

Reply

Joe October 8, 2010 at 12:55 pm

Jammer, this is a terrific hack for an important missing feature. Thank you for the post!!!

Reply

Eli February 6, 2011 at 8:08 am

This was a great tip. Thanks!

Reply

FilterOrder February 9, 2011 at 3:56 pm

In which order are the filters applyed? From top to bottom, or from bottom to top?

Reply

Michael February 9, 2011 at 4:30 pm

Gmail filters are applied from top to bottom.

Reply

FilterOrder February 10, 2011 at 7:29 am

ty ;)

Reply

elastic February 11, 2011 at 3:03 am

I assume that Gmail filters are applied on any order, that more than one filters could hit the same email.
I specify in filter rules a full regular expression in match fields to avoid
any ambiguity, and now Gmail filters seem to work fine.

Reply

FilterOrder February 11, 2011 at 5:19 am

I will try to explain it better. I have an e-main gmail account that retrieves e-mails from other accounts, so i have setup a label for each account. So far so good. The problem starts when i want to filter specific e-mails to other labels.

For example, i want e-mails from:various@newsletters.com to:account2@gmail archived+moved to label:NEWSLETTERS, from:various@foruns.com to:account2@gmail archived+moved to label:FORUNS, etc, and the REMAINING e-mails to:account2@gmail.com archived+moved to label ACCOUNT2. If the last filter is applied first, all e-mails are archived+moved to label ACCOUNT2, and all other filters will not be applied… or will Gmail apply filters to archived mail, too? Because if it does, this will create a huge label messup… folders, anyone?

Reply

Jake March 30, 2011 at 5:39 am

Worked a treat! I had 50 filters. Your process took less than 5 minutes start to finish.

Thanks for sharing this.

Reply

Odilon May 26, 2011 at 7:09 pm

Try edit the filter, when you save, it goes to the end off the list !

Reply

Clif July 1, 2011 at 11:12 am

Worked like a charm, thanks!

Reply

rolfen August 22, 2011 at 6:52 am

You can usually reach your goal by using negative matches.

Example: all mails matching subject “Reply” will go in label “Reply”, and all mail matching subject “-Reply” (does not contain the word reply) will go in label “Others”.

Reply

Leave a Comment

Previous post:

Next post: