How to create a filter in Gmail on a computer
Gmail builds every filter from a search. You describe the messages, check that the search finds the right ones, and then tell Gmail what to do with them.
- Open Gmail in a browser on your computer.
- In the search box at the top, select Show search options, the sliders icon at the right end of the box.
- Fill in only the fields you need: From, To, Subject, Has the words, Doesn't have, Size or Has attachment.
- Select Search and look through the results. If they include mail you want to keep, tighten the criteria and search again.
- Open search options again and select Create filter.
- Tick the actions, such as Skip the Inbox (Archive it), Apply the label or Never send it to Spam.
- To sort the mail you already have as well, tick Also apply filter to matching conversations.
- Select Create filter.
Shortcut from a message: tick the box next to an email, select More (the three dots), then Filter messages like these. Gmail fills in the sender for you.
Want a sender gone rather than sorted? Blocking them in Gmail sends their future mail to Spam without a filter. A filter with Delete it does the same for a whole domain.
What each Gmail filter action does
| Action | What happens |
|---|---|
| Skip the Inbox (Archive it) | The message goes to All Mail without appearing in the inbox. Search still finds it. |
| Mark as read | The message arrives already read, so it doesn't add to your unread count. |
| Star it | Adds a star so the message shows in Starred. |
| Apply the label | Adds a label you choose or create. A message can have several labels. |
| Forward it to | Sends a copy of new matching mail to an address you have verified in Gmail. |
| Delete it | Moves the message to Trash. Gmail empties Trash after 30 days. |
| Never send it to Spam | Keeps matching mail out of Spam, even when Gmail's spam filter would flag it. |
| Always / Never mark it as important | Overrides Gmail's importance marker for these messages. |
| Categorize as | Puts the message in the Primary, Social, Updates, Forums or Promotions tab. |
Search operators you can use in a filter
You can type these in Has the words, or straight into the search box before you select Create filter. Write OR in capitals.
| Operator | Example | Matches |
|---|---|---|
| from: |
from:amazon.com
|
Mail from any address at amazon.com |
| to: |
to:me
|
Mail addressed to you |
| subject: |
subject:(invoice OR receipt)
|
A subject containing either word |
| OR or { } |
{a@example.com b@example.com}
|
Either term |
| - |
-unsubscribe
|
Messages without the word |
| " " |
"order shipped"
|
The exact phrase |
| has:attachment |
has:attachment
|
Messages with any attachment |
| filename: |
filename:pdf
|
Attachments of a type or name |
| larger: / smaller: |
larger:10M
|
Messages over or under a size |
| list: |
list:news@example.com
|
Mail from a mailing list |
| deliveredto: |
deliveredto:you+shop@gmail.com
|
Mail sent to one of your addresses or a +alias |
Operators about a message's state, such as is:unread or
older_than:30d, are only useful for a one-time cleanup: a filter checks each
message once, when it arrives. The full list is in the
Gmail search operators guide.
How to create a Gmail filter on iPhone or Android
The Gmail app for iPhone and Android can't create or edit filters. You can still make one on your phone by opening Gmail's desktop site in a browser.
- Open Safari or Chrome on your phone and go to mail.google.com.
- Switch to the desktop site. In Safari, open the page menu in the address bar and tap Request Desktop Website. In Chrome, open the menu and choose Desktop site (Android) or Request Desktop Site (iPhone).
- Sign in if asked, then follow the computer steps above. Zoom in or turn the phone sideways if the controls are small.
- Go back to the Gmail app. The filter is already working there.
Gmail runs filters on Google's servers, not on your device. A filter you create anywhere applies to new mail on every device: the Gmail app, the website and any mail app connected to the account.
How to apply a Gmail filter to existing emails
Filters act on new mail as it arrives. To run one on the mail already in your account, tick Also apply filter to matching conversations before you select Create filter. For a filter you made earlier:
- Select Settings (the gear icon), then See all settings.
- Open Filters and Blocked Addresses.
- Find the filter and select Edit, then Continue.
- Tick Also apply filter to matching conversations.
- Select Update filter.
Labels, archiving, stars, categories and read status apply to old mail. Forwarding never does. If the filter deletes mail, old matches go to Trash too, so check the search results first. More detail is in applying Gmail filters to existing emails.
How to edit or delete a Gmail filter
- In Gmail on a computer, select Settings (the gear icon), then See all settings.
- Open Filters and Blocked Addresses. Every filter is listed with its criteria and actions.
- To change one, select Edit, adjust the criteria, select Continue, change the actions and select Update filter.
- To remove one, select Delete and confirm with OK.
Deleting a filter doesn't move any mail back. Messages it archived, labeled or deleted stay where they are.
Back up or copy filters: on the same page, tick the filters you want and select Export to download a mailFilters.xml file. Use Import filters at the bottom of the page to add them to another Gmail account. The creator above makes files in the same format.
How to create a rule in Outlook on the web and new Outlook
Outlook calls filters rules. These steps work in Outlook.com, Outlook on the web for Microsoft 365 and the new Outlook for Windows and Mac.
- Select Settings, the gear icon at the top right.
- Select Mail, then Rules.
- Select Add new rule and type a name for it.
- Under Add a condition, choose what to match, such as From, Subject includes or Has attachment. Add more conditions if every one must match.
- Under Add an action, choose what happens, such as Move to, Mark as read, Categorize, Forward to or Delete.
- If some matching messages should be left alone, select Add an exception.
- Stop processing more rules is ticked by default. Clear it if later rules should also act on the same messages.
- Select Save.
Shortcut: in new Outlook, right-click a message, choose Rules, then Create rule. To run a rule on mail you already have, go to Settings, Mail, Rules and select the run icon next to it.
New Outlook doesn't run rules for Gmail, Yahoo or iCloud accounts added to it. Create those filters in the provider's own settings instead.
For ready-made recipes and fixes when a rule stops running, see the Outlook rules guide. To stop a sender outright, block them in Outlook instead of writing a rule.
How to create a rule in classic Outlook for Windows
- On the Home tab, select Rules, then Manage Rules & Alerts. You can also find it under File.
- Select New Rule.
- Under Start from a blank rule, select Apply rule on messages I receive, then Next.
- Tick the conditions, such as from people or public group or with specific words in the subject. Click each underlined value to fill it in, then select Next.
- Tick the actions, such as move it to the specified folder, fill in the underlined values and select Next.
- Add any exceptions and select Next.
- Name the rule. To sort the mail already in your inbox, tick Run this rule now on messages already in "Inbox". Select Finish, then OK.
Outlook marks some rules as client-only. Those run only while Outlook is open on that computer.
How to create a rule in Apple Mail on a Mac
- In Mail, choose Mail > Settings and select Rules. On macOS Monterey and earlier, it's Mail > Preferences.
- Select Add Rule and type a description.
- Choose whether any or all of the conditions must be met, then set them, for example From contains example.com.
- Under Perform the following actions, choose what happens, such as Move Message to a mailbox. Select the add button for more than one action.
- Select OK. Mail asks whether to apply the rule to messages already in your mailboxes: choose Apply or Don't Apply.
To run your rules on existing mail later, select the messages and choose Message > Apply Rules. Rules made in Mail on a Mac run only while Mail is open on that Mac.
iCloud Mail on the web
The Mail app on iPhone and iPad has no rules. If you use an iCloud email address, create rules on iCloud.com instead: they run on Apple's servers and apply on every device.
- Go to icloud.com/mail and sign in.
- Select the Settings button at the top of the Mailboxes list, then choose Settings.
- Select Rules, then Add.
- Name the rule, choose which messages it applies to under Message, and what happens under Action.
- Select Add.
iCloud allows up to 500 rules, applies them in list order, and can take up to 15 minutes to start using a new or changed rule.
How to create a filter in Yahoo Mail
- Select Settings, the gear icon, then More Settings.
- Select Filters, then Add new filters.
- Name the filter.
- Set the rules, such as From or Subject, and what the text contains.
- Choose the folder matching mail should move to, or create a new one.
- Select Save.
Yahoo filters can only move mail to a folder, including Trash. You can have up to 500. When two filters match the same message, the one higher in the list wins, so use the arrows on the Filters page to reorder them.
10 filters worth creating
Each one is a starting point. Select Load into the creator, replace the example addresses, and test the search in Gmail before you create the filter.
-
Newsletters and mailing lists
Nearly every newsletter has an unsubscribe link, so the word catches most of them. Run the search first: some receipts and account emails contain it too.
- Search
-
unsubscribe - Then
- Skip the Inbox (Archive it) · Apply the label: Newsletters
-
Receipts and invoices
Collects purchase confirmations under one label and keeps them out of the inbox. Add the words your shops and suppliers use in their subject lines.
- Search
-
subject:(receipt OR invoice OR "order confirmation") - Then
- Skip the Inbox (Archive it) · Apply the label: Receipts
-
Everyone at one company
Replace example.com with the company's domain. It covers every address at that domain, including people who write to you for the first time.
- Search
-
from:@example.com - Then
- Apply the label: Clients · Never send it to Spam
-
Calendar invitations
Meeting invitations carry an .ics calendar file. Labeling them keeps invites, updates and cancellations together.
- Search
-
filename:ics - Then
- Apply the label: Calendar
-
Large attachments
Labels big files as they arrive, so you know what to clear when storage runs low. Gmail attachments count toward your Google account storage.
- Search
-
has:attachment larger:10M - Then
- Apply the label: Large files
-
Social network notifications
Sends likes, invitations and alerts to the Social tab instead of Primary. Add any other network that emails you.
- Search
-
from:(facebookmail.com OR linkedin.com OR x.com OR instagram.com) - Then
- Categorize as: Social
-
Your boss or most important people
Makes sure mail from one person is never caught by spam filtering, is starred and is marked important. Add more people with commas.
- Search
-
from:boss@example.com - Then
- Star it · Never send it to Spam · Always mark it as important
-
Old promotions cleanup
A one-time cleanup. Filters check mail as it arrives, and new mail is never 30 days old, so this only works on mail you already have: tick Also apply filter to matching conversations, or search and delete by hand.
- Search
-
category:promotions older_than:30d - Then
- Delete it
-
Automated no-reply senders
Labels mail from addresses you can't reply to. Don't make it skip the inbox: sign-in codes and password resets come from no-reply addresses too.
- Search
-
from:(noreply OR "no-reply" OR donotreply OR "do-not-reply") - Then
- Apply the label: Automated
-
Unknown senders
Gmail has no "not in my contacts" condition, so this is an allow list you type by hand: mail to you from anyone not on the list skips the inbox. You have to add every new contact yourself.
- Search
-
to:me -from:(@yourcompany.com OR friend@example.org) - Then
- Skip the Inbox (Archive it) · Apply the label: To screen
Filters and rules in each email app
| App | Called | Where to find it | Where it runs |
|---|---|---|---|
| Gmail | Filter | Search options, then Create filter | Google's servers, so every device |
| Outlook on the web, new Outlook | Rule | Settings, Mail, Rules | Microsoft's servers for Microsoft accounts |
| Classic Outlook for Windows | Rule | Home, Rules, Manage Rules & Alerts | The server, or this PC for client-only rules |
| Apple Mail on a Mac | Rule | Mail, Settings, Rules | This Mac, while Mail is open |
| iCloud Mail | Rule | Settings, Rules on iCloud.com | Apple's servers, up to 500 rules |
| Yahoo Mail | Filter | Settings, More Settings, Filters | Yahoo's servers, up to 500 filters |
Where native filters stop
Filters need to know the sender in advance
Every filter above works from something you already know: an address, a domain, a word in the subject. That handles newsletters, receipts and notifications well. It can't handle the mail that causes most of the noise: people you have never heard from, such as cold sales pitches, recruiters and scams. Gmail, Outlook and Yahoo have no condition for "the sender isn't in my contacts".
You can build an allow list by hand, like the unknown senders example above, but you have to add every new contact yourself, and long lists get hard to maintain. The guide to blocking emails from unknown senders in Gmail compares that with the other options.
KeepKnown adds that missing rule for Gmail and Outlook. It checks each new sender against your contacts and the domains you approve, and moves unknown senders to a KK:OUTSIDERS label instead of deleting them. You can describe other rules in plain English too, and preview which messages a rule would move before anything moves. Other screening tools take different approaches; the SaneBox alternatives comparison covers them.
The audit is free and changes nothing in your inbox. See how contacts-only Gmail works.
Frequently asked questions
How many filters can I create in Gmail?
Google doesn't publish a total limit for personal Gmail accounts, and most people never reach one. For Google Workspace accounts, Google documents a limit of 40 filters that automatically forward mail. Very long filters can fail to save, so split a long list of senders across two or more filters.
Why is my Gmail filter not working?
Run the filter's criteria as a search first. If the search doesn't find the message, the filter won't either, so check the spelling, the exact address and that OR is written in capitals. A filter only acts on mail that arrives after you create it, unless you tick Also apply filter to matching conversations. Every filter that matches a message applies, so look for a second filter that archives or deletes the same mail.
How do I filter emails from several senders at once?
Put the addresses in the From field separated by OR, such as a@example.com OR b@example.com, or wrap them in curly braces: {a@example.com b@example.com}. To cover a whole company, use its domain, such as @example.com. The filter creator on this page accepts a comma-separated list and adds the ORs for you.
Does deleting a filter bring back the emails it moved?
No. Deleting a filter only stops it acting on new mail. Messages it already archived, labeled or deleted stay where they are. Search for the label, or look in Trash, where Gmail keeps deleted mail for 30 days, and move them back yourself.
Can I create a Gmail filter on my phone?
Not in the Gmail app for iPhone or Android. Open mail.google.com in your phone's browser, switch to the desktop site, and create the filter there. It then runs on every device, including the app, because Gmail applies filters on Google's servers.
Do email filters work on emails I already have?
Only if you ask. In Gmail, tick Also apply filter to matching conversations when you create or edit the filter. In new Outlook, run the rule from Settings > Mail > Rules. In Apple Mail, select the messages and choose Message > Apply Rules. Forwarding never applies to old mail.
Can a filter block everyone who isn't in my contacts?
Not in Gmail or Yahoo Mail: neither has a condition for senders who aren't in your contacts. You can list the senders you allow and archive everyone else, but you have to keep that list up to date by hand. KeepKnown adds the missing condition for Gmail and Outlook and moves unknown senders to a label instead of deleting them.
Related guides
Sources: Gmail Help, create rules to filter your emails; Microsoft Support, rules in Outlook; iCloud User Guide, filtering rules; Yahoo Help, filters.