Skip to content
Email & Google WorkspaceAdvanced

Gmail Secret Search Codes and Advanced Search Operators: Find, Clean and Control Unwanted Emails Like a Pro

Most Gmail users type a sender's name or a few words into the search box. However, Gmail's search bar supports a powerful collection of search operators that...

BI
Bison Technical Team Enterprise IT specialists
Updated 16 Aug 2026 16 min read 1 total views

Most Gmail users type a sender's name or a few words into the search box. However, Gmail's search bar supports a powerful collection of search operators that work almost like commands.

For example:

Advertisement

is:unread

finds unread messages, while:

older_than:1y

finds messages older than one year.

You can combine them:

is:unread older_than:1y

to locate messages that are both unread and more than one year old.

These aren't really "secret codes" or hacking commands. They are official Gmail search operators provided by Google. Google also allows multiple operators to be combined to create much more precise searches.

This makes them extremely useful for:

  • Cleaning thousands of old emails
  • Finding unnecessary newsletters
  • Locating unread messages
  • Finding large attachments
  • Identifying emails consuming Gmail storage
  • Finding old promotional messages
  • Separating Social, Promotions and Updates emails
  • Locating emails from a particular sender
  • Finding PDFs, ZIPs, Excel files and other attachments
  • Finding archived messages
  • Searching Spam and Trash
  • Preparing messages for bulk deletion, archiving or labeling

Important: A search operator only identifies matching messages. It does not automatically delete them. Always review the search results before performing a bulk Delete, Archive, Mark as Read or other action.


1. Find All Unread Emails

Use:

is:unread

This displays messages currently marked unread. Google officially supports is:unread, along with status searches such as is:read, is:starred and is:important.

A very useful cleanup command is:

is:unread older_than:1y

This means:

Show unread messages older than one year.

You can change the period:

is:unread older_than:6m

is:unread older_than:2y

is:unread older_than:30d

Here:

  • d = days
  • m = months
  • y = years

2. Find Old Emails

One of the most useful Gmail cleanup operators is:

older_than:1y

It finds messages older than one year.

Other examples:

older_than:30d

Older than 30 days.

older_than:6m

Older than six months.

older_than:2y

Older than two years.

older_than:5y

Older than five years.

Google also supports the opposite operator:

newer_than:

For example:

newer_than:7d

finds messages newer than seven days.


3. Find Gmail Promotions

Use:

category:promotions

This is extremely useful for finding marketing messages, offers and promotional mail classified by Gmail.

Note the spelling: it is promotions, not promptions.

Google currently documents Gmail category searches including primary, social, promotions, updates, forums, reservations, and purchases.

To find old Promotions:

category:promotions older_than:1y

For promotions older than six months:

category:promotions older_than:6m

For unread promotions:

category:promotions is:unread

For old unread promotions:

category:promotions is:unread older_than:1y

This can be an excellent starting point when cleaning a heavily cluttered Gmail account.


4. Find Social Network Emails

Use:

category:social

This can include messages Gmail classifies as Social.

Find Social emails older than one year:

category:social older_than:1y

Find unread Social emails:

category:social is:unread

Find old unread Social emails:

category:social is:unread older_than:1y


5. Find Updates

Use:

category:updates

This category may contain notifications, confirmations, automated updates and similar messages.

For example:

category:updates older_than:2y

Be more careful deleting Updates than Promotions because important confirmations, invoices, account notifications or transaction-related messages may be present.


6. Find Forum Emails

Use:

category:forums

Old forum emails:

category:forums older_than:1y

Unread forum emails:

category:forums is:unread


7. Find Purchase-Related Messages

Gmail also supports:

category:purchases

This can be useful for finding emails associated with purchases.

Example:

category:purchases newer_than:1y

This could help when searching recent purchase-related correspondence.

Avoid bulk-deleting purchase-related messages without checking them because they may contain invoices, receipts, warranties or order information.


8. Find Reservation-Related Messages

Another supported category is:

category:reservations

For example:

category:reservations older_than:2y

This can help identify older reservation-related messages.

Again, review the results before deletion.


9. Find Emails from a Particular Sender

Use:

from:sender@example.com

For example:

from:newsletter@example.com

You can combine this with age:

from:newsletter@example.com older_than:1y

Or unread status:

from:newsletter@example.com is:unread

This is particularly useful when one company or newsletter has sent hundreds or thousands of emails.


10. Find Emails Sent to a Particular Address

Use:

to:user@example.com

This is especially useful if you manage multiple addresses or aliases.

Google also supports:

cc:

and:

bcc:

for searching addresses appearing in those respective fields.


11. Find Emails by Subject

Use:

subject:invoice

Other examples:

subject:renewal

subject:newsletter

subject:offer

subject:password

subject:verification

For an exact phrase, quotation marks can also be useful:

subject:"payment reminder"


12. Search for an Exact Phrase

Use quotation marks:

"payment confirmation"

This searches for the exact phrase rather than simply searching loosely for individual words.

Another example:

"your subscription"


13. Exclude Something from Gmail Search

Use the minus sign -.

For example:

older_than:1y -is:starred

This attempts to find old messages while excluding starred messages.

Another example:

category:promotions -from:importantcompany.com

This can be useful when cleaning Promotions while excluding mail from a sender you want to preserve.

Google notes an important limitation: because Gmail searches conversations, a conversation may sometimes appear with a negative operator when another message in the same conversation satisfies the search criteria.

Therefore, always inspect bulk-delete results.


14. Search Using OR

Suppose you want messages from either of two senders.

Use:

from:company1.com OR from:company2.com

Google also supports braces for matching one or more criteria:

{from:company1.com from:company2.com}

This becomes particularly useful when investigating several recurring senders.


15. Search Using AND

You can explicitly use:

from:accounts@example.com AND is:unread

This requires both conditions to match.

In many ordinary Gmail searches, simply placing compatible operators next to each other also narrows the results.

For example:

from:accounts@example.com is:unread older_than:6m


16. Find Emails with Attachments

Use:

has:attachment

This is one of the most useful operators when investigating mailbox storage.

Combine it with age:

has:attachment older_than:2y

Or:

has:attachment older_than:5y

Before deleting old attachments, verify that they do not contain important business, legal, tax, financial or personal records.


17. Find Large Emails

Use:

larger:10M

This finds messages larger than approximately 10 MB.

Other examples:

larger:5M

larger:20M

larger:50M

You can combine size and age:

larger:10M older_than:1y

Or:

larger:20M older_than:2y

Google officially supports size:, larger: and smaller: searches.

For users trying to reduce Gmail storage usage, this is one of the most valuable searches to run.


18. Find Small Emails

Use:

smaller:1M

For example:

smaller:500K

In most cleanup situations, however, finding large messages provides more storage benefit.


19. Find PDF Attachments

Use:

filename:pdf

Combine it with age:

filename:pdf older_than:3y

Combine it with sender:

from:accounts@example.com filename:pdf

This can be useful for finding invoices, reports, quotations and statements.


20. Find ZIP Attachments

Use:

filename:zip

Example:

filename:zip older_than:1y

ZIP files can sometimes consume significant mailbox space.


21. Find Excel Attachments

Try:

filename:xlsx

or:

filename:xls

You can combine them:

{filename:xls filename:xlsx}


22. Find Word Documents

Try:

filename:doc

or:

filename:docx

For example:

filename:docx older_than:2y


23. Find Emails Containing Google Drive Files

Use:

has:drive

Google also documents specific operators for Google file types:

has:document

has:spreadsheet

has:presentation

These can help locate messages containing Google Docs, Sheets and Slides respectively.


24. Search by Specific Date

Use:

after:2026/01/01

This finds messages after the specified date.

Similarly:

before:2026/01/01

You can combine both:

after:2025/01/01 before:2026/01/01

This creates a date-range search.

It is extremely useful when cleaning emails year by year.


25. Find Emails Before a Particular Date

Example:

before:2020/01/01

This can be useful for locating very old mail.

A safer cleanup search might be:

before:2020/01/01 -is:starred -is:important

But review the results carefully before deleting anything.


26. Find Read Emails

Use:

is:read

Example:

is:read older_than:3y

This can help identify old messages that have already been read.


27. Find Starred Emails

Use:

is:starred

This is useful before performing a large cleanup because you can identify messages deliberately marked for preservation.

For example:

is:starred older_than:5y


28. Find Important Emails

Use:

is:important

Before deleting thousands of old messages, it is worth checking:

is:important older_than:2y

to understand what Gmail has classified as important.


29. Find Archived Emails

Use:

in:archive

For example:

in:archive older_than:2y

Google officially documents in:archive for searching archived messages.


30. Search Everywhere — Including Spam and Trash

Use:

in:anywhere

For example:

in:anywhere "invoice number"

Normally, searches may not behave as users expect when looking for messages in Spam or Trash. in:anywhere explicitly broadens the search to include those locations.

This is particularly useful when you believe an email has disappeared.


31. Find Snoozed Emails

Use:

in:snoozed

For example:

in:snoozed renewal

This searches messages you have snoozed.


32. Find Muted Conversations

Use:

is:muted

Example:

is:muted older_than:1y

Useful for locating old conversations that were muted.


33. Find Mailing List Messages

Use:

list:

For example:

list:news@example.com

Google supports the list: operator for searching mail associated with a mailing list.

This can be helpful when cleaning years of mailing-list traffic.


34. Find Emails Without User Labels

Use:

has:nouserlabels

To find messages with user labels:

has:userlabels

Google notes that these labels apply to messages rather than an entire conversation.


35. Search Emails Delivered to a Particular Address

Use:

deliveredto:user@example.com

This can be especially useful when aliases, forwarding or multiple delivery addresses are involved.


36. Find an Email Using Its Message ID

Advanced administrators and technical users may occasionally have an RFC 822 Message-ID.

Gmail supports:

rfc822msgid:MESSAGE-ID

This is valuable during email troubleshooting, mail-flow investigation and support cases.


Powerful Gmail Cleanup Combinations

The real power of Gmail search appears when several operators are combined.

Old unread messages

is:unread older_than:1y

Old Promotions

category:promotions older_than:1y

Old Social messages

category:social older_than:1y

Old unread Promotions

category:promotions is:unread older_than:1y

Large old messages

larger:10M older_than:1y

Old messages with attachments

has:attachment older_than:2y

Old large attachments

has:attachment larger:10M older_than:2y

Old ZIP files

filename:zip older_than:2y

Old PDFs

filename:pdf older_than:3y

Old read messages

is:read older_than:3y

Old archived messages

in:archive older_than:2y

Promotions excluding starred messages

category:promotions older_than:1y -is:starred

Social messages excluding starred messages

category:social older_than:1y -is:starred

Large old mail excluding starred messages

larger:10M older_than:2y -is:starred


Recommended Gmail Cleanup Sequence

If your Gmail account contains tens of thousands of messages, don't immediately search for everything older than several years and delete it.

A controlled cleanup sequence is safer.

Step 1 — Clean old Promotions

Search:

category:promotions older_than:1y

Review the results.

If appropriate, select the unwanted messages and delete them.

Step 2 — Clean old Social messages

Search:

category:social older_than:1y

Again, review before deleting.

Step 3 — Find old unread mail

Search:

is:unread older_than:1y

Messages that have remained unread for years may include newsletters and automated notifications that are no longer useful.

Step 4 — Find large emails

Search:

larger:10M

Then consider:

larger:10M older_than:1y

This can produce much greater storage savings than deleting thousands of tiny text emails.

Step 5 — Find old attachments

Search:

has:attachment older_than:2y

Review carefully.

Step 6 — Check ZIP and other large file attachments

Try:

filename:zip older_than:2y

and:

filename:pdf older_than:3y

Step 7 — Check important and starred mail before aggressive cleanup

Run:

is:starred

and:

is:important

This gives you a better understanding of messages that should potentially be protected.


How to Bulk Delete Search Results

After running a Gmail search:

  1. Review several pages of results first.
  2. Click the checkbox at the top to select the displayed conversations.
  3. Gmail may offer an option to select all conversations matching the search.
  4. Use Delete only after verifying the search criteria.
  5. For messages you may need later, consider Archive instead.
  6. For messages you simply no longer want highlighted as unread, consider Mark as read instead of deleting them.

Gmail also allows search results to be used as the basis for filters, making operators useful not only for historical cleanup but also for future inbox management.


Creating Automatic Gmail Filters from Search Criteria

Suppose you repeatedly receive unnecessary newsletters from:

newsletter@example.com

Search:

from:newsletter@example.com

After confirming that the search identifies the correct messages, you can create a Gmail filter based on those criteria.

Depending on your requirement, a filter can then help Gmail automatically perform actions such as applying a label, skipping the Inbox or deleting matching messages.

Be especially cautious with automatic deletion rules. A sender may later send an important security, billing, account or service notification from the same address.


Useful Searches for Business Gmail Accounts

Business users should be more conservative because old emails may contain invoices, agreements, quotations, tax records, payment confirmations and customer correspondence.

A better approach is to target obviously unnecessary categories first.

For example:

category:promotions older_than:2y

followed by:

category:social older_than:2y

and then:

larger:10M older_than:2y

Avoid blindly deleting searches such as:

older_than:2y

from a business mailbox.

That search may include critical historical correspondence.


Search for Potential Security Messages

You can also use Gmail search for investigations.

Examples:

subject:"security alert"

subject:"new sign-in"

subject:"password reset"

subject:"verification code"

These are ordinary keyword/subject searches rather than special security commands, but they can be useful when investigating account-related notifications.

You could narrow the search by date:

subject:"security alert" newer_than:1y

Do not treat the presence or absence of these messages as proof that an account is secure or compromised.


Gmail Cleanup Commands Cheat Sheet

Requirement Search
All unread emails is:unread
Emails older than 1 year older_than:1y
Emails older than 2 years older_than:2y
Unread emails older than 1 year is:unread older_than:1y
Promotions category:promotions
Old Promotions category:promotions older_than:1y
Social messages category:social
Old Social messages category:social older_than:1y
Updates category:updates
Forums category:forums
Purchases category:purchases
Reservations category:reservations
Messages with attachments has:attachment
Messages larger than 10 MB larger:10M
Large old messages larger:10M older_than:1y
PDF attachments filename:pdf
ZIP attachments filename:zip
Excel attachments filename:xlsx
Word attachments filename:docx
Starred emails is:starred
Important emails is:important
Read emails is:read
Archived emails in:archive
Snoozed emails in:snoozed
Muted conversations is:muted
Search including Spam/Trash in:anywhere
Messages with user labels has:userlabels
Messages without user labels has:nouserlabels
Emails from a sender from:user@example.com
Emails to an address to:user@example.com
Search subject subject:keyword
Before a date before:2026/01/01
After a date after:2026/01/01

10 Powerful Commands Worth Remembering

For everyday Gmail management, these ten combinations cover a large percentage of cleanup requirements:

is:unread older_than:1y

category:promotions older_than:1y

category:social older_than:1y

category:updates older_than:2y

has:attachment older_than:2y

larger:10M

larger:10M older_than:1y

filename:zip older_than:2y

is:read older_than:3y -is:starred

in:anywhere "search phrase"


Important Precautions Before Bulk Deleting Gmail

Search operators are powerful precisely because they can identify thousands of messages at once.

Before bulk deletion:

Check the search query carefully.

category:promotions older_than:2y

is very different from:

older_than:2y

The second query is far broader.

Protect important correspondence.

Consider whether your mailbox contains:

  • Tax documents
  • GST-related records
  • Invoices
  • Purchase receipts
  • Customer correspondence
  • Contracts
  • Legal notices
  • Banking correspondence
  • Password/security notifications
  • Domain or hosting information
  • Software licences
  • Warranty documents

Review before deleting.

Never assume every message Gmail categorizes in a particular way is disposable.

For business accounts, follow your retention requirements.

Companies may have contractual, statutory, compliance, litigation-hold or internal retention requirements. Mailbox cleanup should not override those requirements.


Frequently Asked Questions — FAQ

1. What is is:unread in Gmail?

is:unread is a Gmail search operator that finds messages currently marked as unread.


2. What does older_than:1y mean?

It means:

Find emails older than one year.

You can similarly use older_than:6m for six months or older_than:30d for 30 days.


3. What does is:unread older_than:1y do?

It combines two conditions and searches for emails that are unread and older than one year.


4. How do I find all promotional emails?

Use:

category:promotions


5. How do I find Promotions older than one year?

Use:

category:promotions older_than:1y


6. Is the command category:promptions correct?

No.

The correct spelling is:

category:promotions


7. How do I find Social emails?

Use:

category:social


8. How do I find old Social emails?

Use:

category:social older_than:1y


9. How can I find emails consuming a lot of Gmail storage?

Start with:

larger:10M

You can increase the threshold:

larger:20M

or:

larger:50M


10. How do I find large old emails?

Use:

larger:10M older_than:1y


11. How can I find emails with attachments?

Use:

has:attachment


12. How can I find old attachments?

Use:

has:attachment older_than:2y


13. How can I find PDF attachments?

Use:

filename:pdf


14. How can I find ZIP attachments?

Use:

filename:zip


15. Can Gmail search operators be combined?

Yes. Combining operators is one of their most powerful features.

For example:

category:promotions is:unread older_than:1y

Google officially supports combining search operators to refine results.


16. How can I find messages from one sender?

Use:

from:sender@example.com


17. How do I search for emails before a specific date?

Use:

before:YYYY/MM/DD

For example:

before:2025/01/01


18. How do I search within a date range?

Use after: and before: together.

For example:

after:2025/01/01 before:2026/01/01


19. How can I exclude starred emails from cleanup?

You can add:

-is:starred

For example:

category:promotions older_than:1y -is:starred

Remember that Gmail's conversation-based matching can sometimes make negative searches behave differently than expected, so inspect the results before deleting.


20. How do I search Spam and Trash too?

Use:

in:anywhere

For example:

in:anywhere "invoice"

This expands the search to include Spam and Trash.


21. Can I automatically delete emails using these commands?

Search operators themselves only find messages. However, Gmail can use search criteria when creating filters.

Automatic deletion should be used cautiously, particularly on business accounts.


22. What is the best Gmail command for cleaning storage?

There is no single perfect command, but a useful starting point is:

larger:10M

Then try:

larger:10M older_than:1y

This targets messages that have a greater potential storage impact.


23. Should I delete every email older than five years?

Not automatically.

Business, financial, legal, tax, purchase, warranty and other important records may need to be retained.


24. Can these commands be used in Google Workspace Gmail?

The Gmail search operators apply to Gmail, including Gmail used through Google Workspace, subject to account features and administrative policies.


25. Are these really secret Gmail codes?

Technically, no. They are Gmail search operators. They may feel like hidden or secret commands because many Gmail users never use them, but Google officially documents them.

For Google's current operator reference, see Google's official Gmail search-operator guide.


Conclusion

Gmail's search box is far more powerful than a normal keyword-search field. Operators such as is:unread, older_than:, category:, larger:, filename:, has:attachment, from:, before: and after: can turn it into a practical mailbox-management tool.

For a heavily cluttered mailbox, a sensible starting sequence is:

category:promotions older_than:1y

then:

category:social older_than:1y

then:

is:unread older_than:1y

then:

larger:10M older_than:1y

and finally:

has:attachment older_than:2y

The key principle is search first, review second, delete third. Gmail's advanced operators can locate thousands of unwanted messages very quickly, but bulk deletion should always be performed carefully—especially on business or professional accounts.

#Tags

#Gmail #GmailTips #GmailTricks #GmailSearch #GmailSearchOperators #GmailCommands #GmailSecretCodes #GmailCleanup #EmailCleanup #InboxCleanup #GmailStorage #EmailManagement #InboxManagement #GmailAdvancedSearch #GoogleGmail #GoogleWorkspace #GoogleWorkspaceTips #EmailTips #EmailProductivity #GmailProductivity #GmailFilters #GmailUnread #GmailPromotions #GmailSocial #GmailUpdates #GmailAttachments #GmailStorageCleanup #DeleteOldEmails #BulkDeleteGmail #CleanGmail #CleanInbox #EmailOrganization #GmailSecurity #GmailAdmin #GoogleWorkspaceAdmin #GmailPowerUser #GmailCheatSheet #GmailTutorial #GmailGuide #GmailHelp #EmailSearch #AdvancedEmailSearch #GmailOperators #MailboxCleanup #MailboxManagement #GmailLargeEmails #GmailOldEmails #GmailAttachmentSearch #GmailInbox #TechTips

YOUR FEEDBACK

Was this guide useful?

Your answer helps us keep BISONKB accurate and practical.

BISON AI

Ask about “Gmail Secret Search Codes and Advanced Search Operators: Find, Clean and Control Unwanted Emails Like a Pro”

This interface is ready to connect to your preferred AI provider. No article or user data is sent until that service is configured.

THE BISON BRIEF

Practical IT knowledge, once a week.

New troubleshooting guides, scripts and infrastructure notes. No noise.

By subscribing, you agree to our privacy policy.