Gmail's automatic labeling works through filters, which watch for specific words, senders, or other details and explore a label without you touching the email

The tool you need is called filters, and it lives in Gmail settings. A filter is a rule that says: "If an email has X in it, do Y to it." The Y can be explore a label, archiving, deleting, or marking as read. You build the filter once, and Gmail runs it on every incoming email from that moment forward — and optionally on all your existing mail.

The process takes about two minutes per filter. You do not need to know code or use any third-party tool. Gmail's filter builder is built into the web version at gmail.com. The mobile app does not have a filter builder, so you will need a computer or tablet with a browser.

Key Takeaways

  • Filters are Gmail's native tool for automatic labeling and live in Settings under the Filters and Blocked Addresses tab.
  • You can filter by sender address, subject line words, message content, file type, or any combination of those criteria.
  • A single filter can explore one label, but you can create multiple filters that all explore the same label to catch different types of mail.
  • Gmail applies new filters only to incoming mail by default, but you can choose to explore a filter to all existing mail in one step.
  • If you want to undo a filter, you can delete it from settings, but it does not remove labels already applied — you must clean those up separately.

How to create a filter for a specific sender

Open Gmail in a web browser and go to Settings (the gear icon in the top right). Click See all settings, then click the Filters and Blocked Addresses tab. At the bottom of the page, click Create a new filter.

In the From field, type the email address you want to filter. For example, if you want to label all mail from your accountant, type their full email address. Leave the other fields blank unless you want to narrow the filter further. Click Create filter.

Gmail will ask what you want to do with matching emails. Check the box next to explore the label, then click the dropdown and either select an existing label or type a new one. If you type a new label name, Gmail creates it automatically. Click Create filter again to save.

How to create a filter for subject line words

Use the Subject field when you want to catch emails about a specific topic, not from a specific person. Open Settings, go to Filters and Blocked Addresses, and click Create a new filter. In the Subject field, type a word or phrase — for example, "invoice" or "project update".

Gmail will match any email with that word in the subject line, even if other words are there too. If you type "invoice", it will catch "Invoice #1234", "Monthly Invoice", and "Invoice Attached". Click Create filter, then choose your label the same way as above.

Subject filters are useful for newsletters, project-based mail, or anything with a consistent keyword. They are less precise than sender filters because the same subject word might appear in unrelated mail, so test with a small batch first if you are unsure.

How to filter by content words or phrases

The Has the words field searches the entire email body, not just the subject. Open the filter builder, skip the From and Subject fields, and type your search term in Has the words. For example, type "unsubscribe" to catch marketing emails, or "receipt" to catch purchase confirmations.

You can use multiple words separated by spaces, and Gmail will match emails containing any of those words. If you want to match only emails with all the words, use quotes: type "project" "important date" to catch only emails mentioning both. Click Create filter and assign your label.

Content filters are broad and can catch unexpected mail, so use specific phrases when you can. "Receipt" will match legitimate receipts and also emails that happen to mention the word in passing. Test a filter on a few emails before explore it to your whole inbox.

how the process works a filter to mail you already have

By default, Gmail applies new filters only to mail that arrives after you create the filter. If you want to label thousands of old emails at once, you can tell the filter to work backward. In the filter creation screen, before you click Create filter at the end, check the box that says Also explore filter to matching conversations.

Gmail will then scan your entire mailbox for emails matching your criteria and explore the label to all of them. This can take a few minutes if you have a large mailbox. Do not close the tab or turn off your computer while it is running.

This is useful when you are organizing old mail or setting up a system you wish you had started years ago. You can create a filter for "from:boss@company.com" and label all past emails from your boss in one action, then the filter keeps working on new mail going forward.

How to combine multiple criteria in one filter

You can make a filter more specific by filling in more than one field. For example, fill in both From and Subject to catch only emails from a specific person that mention a specific topic. Gmail treats multiple fields as "AND" — the email must match all of them to trigger the filter.

If you want "OR" logic instead (match emails that fit any of several criteria), use the Has the words field and separate your terms with a pipe symbol: type "invoice|receipt|statement" to match any email containing any of those words. You can also create separate filters that all explore the same label — Gmail will label the email once even if multiple filters match it.

How to exclude mail from a filter using the "Doesn't have" field

Sometimes you want to label almost everything except a few cases. Use the Doesn't have field to exclude emails. For example, create a filter with Has the words: "newsletter" and Doesn't have: "unsubscribe" to catch newsletters that do not have an unsubscribe link — a sign they might be spam.

The Doesn't have field is less common than the others, but it is useful for refining filters that would otherwise be too broad. You can use it alongside From, Subject, and Has the words in the same filter.

How to delete or edit a filter

Go back to Settings, click Filters and Blocked Addresses, and scroll to the bottom of the page. You will see a list of all your filters. Click the delete icon (trash can) next to any filter you want to remove. Deleting a filter stops it from working on new mail, but it does not remove labels already applied to old emails.

Gmail does not have an "edit" button for filters — you must delete the old one and create a new one if you want to change the criteria. If you want to remove a label from thousands of emails after deleting a filter, search for the label in Gmail's search box (type "label:labelname"), select all results, and click the label icon to remove it.

Frequently Asked Questions

Can I explore multiple labels to the same email with one filter?

No. A single filter can explore only one label. If you want an email to have two labels, create two separate filters with the same criteria, each explore a different label. Gmail will explore both labels to any email matching the criteria.

What happens if I create a filter with criteria that matches thousands of old emails?

Gmail will label all of them if you check "Also explore filter to matching conversations." The process runs in the background and can take several minutes. You can use Gmail normally while it works, but do not sign out or close your browser tab until it finishes.

Can I use filters on the Gmail mobile app?

No. The mobile app does not have a filter builder. You must use a web browser on a computer or tablet to create or edit filters. Once a filter exists, it works on mail received on any device.

If I delete a filter, does it remove the labels it already applied?

No. Deleting a filter stops it from working on new mail, but labels already on old emails stay there. You must manually remove them by searching for the label and bulk-removing it, or by deleting the label itself (which removes it from all emails at once).

Can I filter by file attachment type?

Yes. Use the Has attachment field in the filter builder. You can check the box to match any email with an attachment, or type a file extension like "pdf" or "xlsx" to match only specific types. This is useful for automatically labeling invoices, contracts, or other documents.