How to Use Gmail Search Operators

Gmail Search Operators

Looking to find emails with precision in Gmail (“messages from Anu in the last two days that have an attachment but do not talk about tennis”) or set up advanced filters? Find here search operators you can use in Gmail search and for setting up filtering rules.

First Dark Green, Then Yellow

A square filled with dark green followed by one in yellow prints a character to the console, of course, and light blue after bright cyan adds two numbers from the stack.

In the wonderful Piet programming language, changes in brightness and hue make for abstract paintings with concrete meanings: each change represents an operator or command. Two steps of hue (in a rolling preset list of six) combined with 2 steps of darkening (again rolling over) stand for the (logical) operator not, for instance.

Now, setting up searches and filters is, alas, less colorful in Gmail. It includes operators, though, and one for not as well:

How to Use Gmail Search Operators for Advanced Search and Rules

To create advanced searches in Gmail and to set up advanced rules, use these Gmail search operators:

Sender and Recipient Search Operators

Gmail Search OperatorFunction
from:The email address or name, or parts of either in the From: header line.
Examples
from:heinz@ladedu.com – all emails with heinz@ladedu.com in the From: line
from:@ – all emails with the @ symbol in the From: line; essentially all emails
to:The email address or name, or parts of either for the direct recipient in the To: header line.
Example: to:me+nl@gmail.com – all emails with me+nl@gmail.com in the To: line (but not me@gmail.com, for instance)
cc:The email address or name, or parts of either in the Cc: header line.
Examples
cc:me@gmail.comme@gmail.com appears in the Cc: header line
cc:janeJane appears either as part of an email address or name as a CC recipient
bcc:The email address or name, or pets of either in the Bcc: header line.
Search only: This operator is not available for Gmail rules; only emails you have sent from Gmail will contain the Bcc: field.
Example: bcc:jane – emails sent as copies to “jane” (as part of an email address or name)

Subject, Content and Label

Gmail Search OperatorFunction
subject:Words in the Subject: header line.
Gmail will look for word variations and partial matches as well, and searches are not case-sensitive
Example: subject:la de du – emails with the words la, de and du in the subject
+Look for the exact word only. Matches are not case sensitive, though
Example: +ladedu – matches ladedu but not ladedus, for example
label:Searches a particular label (Gmail folder); also works for the label important.
Examples
label:ladedu – all emails that are labelled ladedu
label:important label:ladedu – important emails in the folder ladedu

Date Search Operators

Gmail Search
Operator
Function
before:
after:
Messages sent or received before or after a certain (absolute) date.
Use “YYYY/MM/DD” or “MM-DD-YYYY”, for example, to specify dates.
Example: before:2014/04/14 – all emails sent or received before April 14, 2014
older_than:
newer_than:
Messages sent or received before or after a date relative to now.
You can specify the time period in hours (h), days (d), months (m) and years (y)
Example: newer_than:2d – emails received or sent today or yesterday

Attachment and Size Search Operators

Gmail Search
Operator
Function
has:attachmentMessages that include at least one attached file.
Example: from:@ladedu.com has:attachment – Emails with an attachment from somebody whose email address includes @ladedu.com
filename:Searches the file name or file type (f it is part of the file name as an extension) of attachments.
Example: filename:pdf – finds all PDF document attachments
larger:
smaller:
Search for total message size (the email itself plus all attachments) exceeding or being smaller than a limit.
Specify the size in kB (K) or MB (M).
Example: larger:10M – all emails larger than 10 MB

Miscellaneous Headers Gmail Search Operators

Gmail Search
Operator
Function
list:A mailing list as established by Gmail.
This draws from the From:, To: and List-ID: headers, for instance, but also includes messages sent through prominent email list providers.
Example: list:ladedu – emails sent though the La De Du mailing list
rfc822msgid:Look for exact email and conversation matches using the Message-ID: email header.
Example: rfc822msgid:26c82da7@ladedu.com – find the precise message

Logical and Grouping Search Operators

Gmail Search OperatorFunction
-Exclude matches.
Example: -to:me+ladedu@gmail.com – all emails that do not have me+ladedu@gmail.com in the To: email header
AND or  (whitespace)Return all emails that match both search terms; if you separate search terms by whitespace, this is the default.
Example: from:@ladedu.com AND subject: la de du – messages from an email address at the domain ladedu.com that have the words la, de and du in the Subject: header line
OR or |Find emails matching one term or the other or both.
Example: from:@ladedu.com OR subject:la de du – emails either with an email address that includes @ladedu.com in the From: line or la de du in the Subject: line (or both)
()Group search terms and operators, especially to combine them.
Example: from(ladedu.com|gmail.com) -(subject:tennis OR has:attachment) – emails that come from either ladedu.com or gmail.com and do have neither tennis in the subject line nor an attachment

Gmail Search Operators for Advanced Search and Rules: FAQ

Which search operators can I use in filters?

You can use all search operators above in Gmail rules to filter incoming mail (to move it to a folder automatically, for instance) with the following exceptions:

  • bcc: and
  • date and time search operators.

Do the search operators also work in Gmail Basic HTML and the Gmail apps?

Yes.

The Gmail search operators work in every Gmail search field, with Gmail in a desktop browser, mobile Gmail, the Gmail apps for iOS and Android as well as Basic HTML Gmail.

(Gmail search operator for advanced search and rules updated January 2024)

Home » Email Tips and Resources » Gmail Tips and Resources » How to Use Gmail Search Operators