Start from a common search
Your Gmail search
Open this search in GmailOpens Gmail in a new tab, in the account you are signed in to. Check the results before you delete anything.
Turn it into a filter
A filter does this to every new email that matches, as it arrives.
Delete it sends every new match straight to Trash, and Gmail empties Trash after 30 days. Pick Skip the Inbox if you are not sure.
See the file
Import the filter into Gmail
- In Gmail on a computer, click the gear icon at the top right, then See all settings.
- Open the Filters and Blocked Addresses tab.
- At the bottom of the page, click Import filters, choose the mailFilters.xml file you downloaded, and click Open file.
- Click Create filters.
Filters act on new mail. Gmail runs a filter on each email as it arrives, so mail already in your account is left alone. To include it, tick Apply new filters to existing email on the import screen before you click Create filters. When you make a filter by hand, the same choice reads Also apply filter to matching conversations.
That is also why "Older than" and "Is unread" stay out of the filter file: a new email is never old and always unread. Use those two in the search. Importing works in Gmail on a computer, not in the phone app.
How Gmail search operators work
Type these into the search box at the top of Gmail. Put a space between operators to require all of them.
| Operator | What it finds | Example |
|---|---|---|
from: | Email from a sender or a whole domain | from:example.com |
to: | Email sent to an address | to:you+shopping@gmail.com |
subject: | Words in the subject line | subject:invoice |
" " | An exact phrase | "order confirmation" |
OR or { } | Any one of several things | {from:amy@example.com from:david@example.com} |
- | Leaves something out | unsubscribe -receipt |
( ) | Groups words so one operator covers all of them | subject:(dinner movie) |
has:attachment | Email with a file attached | has:attachment from:example.com |
larger: smaller: | Email over or under a size. M is megabytes, K is kilobytes | larger:10M |
older_than: newer_than: | Age in days (d), months (m) or years (y) | older_than:1y |
category: | One inbox category: primary, promotions, social, updates or forums | category:promotions |
is:unread | Email you have not opened | is:unread older_than:6m |
Source: Google's Gmail Help page on search operators, read November 14, 2026.
Or let Inbox Hero do this
Inbox Hero is an AI email assistant for Gmail, Yahoo, AOL, iCloud and other IMAP mailboxes that sorts new mail into folders, checks every new email for scams and phishing, and drafts replies in your voice.
- No filters to write. New mail is sorted into Fraud, Later, Newsletters, Notifications and Shopping folders as it arrives, and the backlog is filed too.
- Your own rules in a tap. Block a sender, or choose Always file like this to send their mail to a folder.
- Every new email is checked for scams and phishing. Clear scams go to the Fraud folder.
27¢ a day ($99 a year) after a 14-day free trial: $0 today, card at sign-up, cancel any time.
Frequently asked questions
Is the Gmail filter builder free?
Yes. It is free and needs no sign-in. It runs in your browser, so the senders and words you type are not sent to Inbox Hero or anyone else.
What is the difference between a Gmail search and a filter?
A search finds email you already have. A filter is a saved search plus an action, such as Skip the Inbox or Delete it, that Gmail runs on each new email that matches.
Can a Gmail filter delete old emails?
Not by age. A filter runs on each email as it arrives, so "older than" cannot be part of one. To delete old mail, copy the search, open it in Gmail, select all conversations that match and click Delete.
How do I import a filter file into Gmail?
In Gmail on a computer, open Settings, then See all settings, then Filters and Blocked Addresses. At the bottom, click Import filters, choose the mailFilters.xml file, click Open file, then Create filters.
How do I search for several senders at once in Gmail?
Put them in braces, like {from:amy@example.com from:david@example.com}, or write OR in capital letters between them. The builder does this for you when you separate senders with commas.
Will the filter change email I already have?
Only if you ask it to. Filters act on new mail. On the import screen, tick Apply new filters to existing email if you want the same action on matching mail already in your account.