Advanced Gmail Filters That Aren't Available in Gmail

Gmail filters help you automatically sort email messages based on rules. So if your boss has sent an email message, the filter can mark it as important. If the email has the word “Unsubscribe” somewhere in the message body, it can be marked as a promotional message and so on.

How to Create Advanced Gmail Filters

While the built-in Gmail filters are powerful, they do have certain limitations.

For instance, you cannot have a Gmail filter that does case-sensitive search. It will treat WHO and who as same. Gmail filters won’t do pattern matching (regular expressions) so you cannot have a filter for messages that contain phone numbers.

We often get spam messages that have a few dozen addresses in the TO and CC fields but there’s no filter to automatically redirect such messages to the SPAM folder of Gmail. That’s where Google Scripts can help. You can setup advanced filters that aren’t available in the native version of Gmail.

Advanced Gmail Filters

What you see above is a set of 10 Gmail filters that were created with Apps Script. You can have a filter to process messages that contain tons of links. Or messages that have too many attachments. Or messages that have just a word or two in the message body.

The best part is that you don’t have to know scripting to use either of these filters. Just follow these 3 easy steps:

  1. Click here to copy the Gmail Filters sheet into your Google Drive. You can write OFF to deactivate any of the available rules.
  2. Go to the Gmail Filters menu in the sheet, choose Initialize and grant the necessary permissions to the script.
  3. Now choose Turn-on Gmail Filter to activate your filters. You may close the Google sheet now.

Here’s what happens behind the scenes. The script will run in the background every 10 minutes and monitor any new unread messages in your Gmail inbox. It will then run the various rules against these messages. The native filters in Gmail take precedence and then your custom rules specified in the sheet are applied.

You can also look at the source code to understand how the various rules were created.


Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory


Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.