Gmail search operators, each with a working example
Gmail's search box understands a small query language, and almost nobody uses more than from: and subject: of it. The rest is what turns "find that one email" into a search that returns exactly one message, and it is also, operator for operator, the language Gmail filters are written in — a filter is a saved search with an action attached. Learn to search well and you already know how to write a filter.
Every operator below is typed straight into the Gmail search box, and most combine with a space between them, which Gmail treats as AND. Type from:amazon.com has:attachment and you get mail from Amazon that has an attachment, not either condition on its own.
Who sent it or received it
| Operator | Matches | Example |
|---|---|---|
| from: | Mail from a specific address or domain | from:billing@vendor.com |
| to: | Mail sent to a specific address | to:you@gmail.com |
| cc: | Mail where the address is copied | cc:manager@work.com |
| bcc: | Mail you blind-copied — only reliable for mail you sent | bcc:list@company.com |
| deliveredto: | The address mail was actually delivered to — useful behind an alias or forward | deliveredto:alias@yourdomain.com |
The domain trick worth knowing: Gmail has no wildcard character. A * does not mean "anything": from:(bill*@vendor.com) finds nothing, not even billing@vendor.com. To match every address at a domain, write the domain on its own: from:(@vendor.com) matches billing@vendor.com, support@vendor.com, all of it, with no asterisk needed.
What it says
| Operator | Matches | Example |
|---|---|---|
| subject: | Words in the subject line | subject:invoice |
| "exact phrase" | An exact phrase, anywhere in the message | "quarterly report" |
| -word | Excludes messages containing a word | dinner -restaurant |
| word1 OR word2 | Either term — write out OR, lowercase or does not work | from:amy OR from:bob |
Attachments and embedded content
| Operator | Matches | Example |
|---|---|---|
| has:attachment | Any file attached to the message | has:attachment |
| filename: | A specific file name or extension | filename:pdf |
| has:drive | A linked Google Drive file | has:drive |
| has:document / has:spreadsheet / has:presentation | A linked Doc, Sheet, or Slides file | has:spreadsheet |
| has:youtube | A linked YouTube video | has:youtube |
Where it lives
| Operator | Matches | Example |
|---|---|---|
| in:anywhere | Every message, including Spam and Trash | in:anywhere invoice |
| in:inbox / in:trash / in:spam / in:snoozed | Just that location | in:trash |
| label: | A specific label | label:receipts |
| category: | A specific inbox tab | category:promotions |
Status
| Operator | Matches | Example |
|---|---|---|
| is:unread / is:read | Read state | is:unread |
| is:starred | Starred messages | is:starred |
| is:important | Messages Gmail's own ranking marked important | is:important |
| is:muted | Conversations you muted | is:muted |
When it arrived
| Operator | Matches | Example |
|---|---|---|
| after: / before: | On or after / on or before a date, written yyyy/mm/dd | after:2026/01/01 |
| older_than: / newer_than: | Relative age — a number plus d, m, or y | older_than:1y |
Size
| Operator | Matches | Example |
|---|---|---|
| larger: | Messages above a size — a number plus a unit, K or M | larger:10M |
| smaller: | Messages below a size | smaller:1M |
Combining operators
Four rules cover every combination above: a space between terms is AND; OR (capitalised) means either; a leading - excludes; and parentheses group terms so a domain or an OR applies to everything inside them rather than just the word next to it. from:(alice@x.com OR bob@x.com) has:attachment -in:trash reads left to right exactly as it looks: from either address, with an attachment, not in Trash.
Why this is worth learning before you write a filter
A Gmail filter's Has the words field takes this syntax — there is no separate, simpler filter language to learn. One caveat: a filter runs as each message arrives, so operators about what happens to mail later (is:, in:, label:, older_than:) are unreliable there. For the rest, you can test a filter before it exists: type the criteria into the search box first, read the results, and only turn it into a filter once the search returns the right mail.
That is also the fastest way to debug one that already exists — paste its criteria back into search and see what actually matches today, rather than what you assume it matches. We built Gmail Filters to skip the copy-paste: describe what you want in plain English, and it writes the operator syntax above, runs it against your real inbox so you see every match before anything is applied, and can apply the result backwards over mail that already arrived.
Stop guessing whether a filter works. Gmail Filters runs your filter against your real inbox and shows you every message it catches before you apply anything — then applies it backwards over the mail your broken filter missed.
Try it free