Gmail Filter Rule Generator
Gmail filter generator that builds search queries from sender, subject, keyword, size, and date conditions, with the exact syntax and setup steps. Free.
Matches emails from this address.
Matches emails sent to this address.
Emails with these words in the subject line.
Emails containing these words anywhere. Multiple words = AND logic.
Exclude emails containing these words.
Set at least one condition above to see how to create the filter.
What this Gmail filter generator does
This tool converts your filter conditions into the exact search syntax Gmail uses to match messages. Instead of memorizing operators like from:, subject:, and has:attachment, you pick your criteria from the form and get a ready-to-use query plus step-by-step setup instructions.
from: — Sender email
to: — Recipient email
subject: — Words in subject
has:attachment — With file
larger: smaller: — Size
newer_than: older_than: — Date
✦ Auto-label invoices from your accounting system
✦ Skip the inbox for shipping notifications
✦ Mark read for newsletters you never open
✦ Delete emails from known spammy senders
✦ Star emails from your manager with “urgent” in the subject
✦ Categorize receipts and expense reports
Every filter you write is a rule you'll maintain forever.
NeatMail sorts your inbox without any of them — labeling by meaning instead of matching strings, archiving the noise, and catching the promises a filter would have quietly swept past.
About the Gmail Filter Rule Generator
A Gmail filter generator is a tool that builds Gmail's search-operator syntax for you so you can automatically label, archive, forward, or delete matching emails. You pick conditions like sender, subject, keywords, size, or date, and it outputs the exact query — using operators such as from:, subject:, and has:attachment — plus step-by-step instructions for turning it into a saved filter in Gmail settings.
Which Gmail search operators work in a filter
A filter is a saved search that Gmail runs against each message as it arrives. That one fact decides which operators are worth putting in one. Anything describing the message itself (who sent it, what it says, what's attached) works. Anything describing what has happened to a message since it arrived (its age, its labels, whether you've read it) only makes sense in a search you run once.
| Operator | What it matches | Example | In a filter? |
|---|---|---|---|
| from: / to: / cc: / bcc: | Sender or recipient address or name | from:amy@example.com | Yes |
| subject: | Words in the subject line | subject:(invoice receipt) | Yes |
| "quotes" | An exact phrase | "order confirmation" | Yes |
| OR, { }, -, ( ) | Either term, exclusion, grouping | from:amy OR from:david | Yes |
| AROUND | Two words within N words of each other | invoice AROUND 5 overdue | Yes |
| has:attachment / filename: | Any attachment, or one by name or type | filename:pdf | Yes |
| larger: / smaller: / size: | Message size, in bytes or with M for megabytes | larger:10M | Yes |
| list: | Mail sent through a mailing list | list:info@example.com | Yes |
| deliveredto: | The address the message was delivered to, useful for aliases and forwarded accounts | deliveredto:you@example.com | Yes |
| newer_than: / older_than: / after: / before: | Message age or date | older_than:1y | Cleanup only: a new message is always seconds old |
| is:unread / is:starred / label: / in: | What has happened to a message since it arrived | is:unread label:clients | Cleanup only |
That is why the date range in this generator is for clearing out mail you already have. Build the query, open Create filter, and tick Also apply filter to matching conversations: Gmail applies the action to everything that matches today. For mail that arrives later, leave the date out, or the filter will match everything (newer_than) or nothing (older_than). The operator list and examples come from Google's Gmail search operators page. For the whole setup, from creating the label to fixing a filter that catches the wrong mail, see how to auto label emails in Gmail.
Eight Gmail filters worth copying
Paste any of these into the fields above, or straight into Gmail's search bar, then swap the example addresses for your own.
| Goal | Query | Actions to tick |
|---|---|---|
| Receipts out of the inbox | subject:(receipt OR invoice OR "order confirmation") | Skip the Inbox, Apply the label: Receipts |
| Newsletters into one place | unsubscribe -from:me | Skip the Inbox, Apply the label: Reading. Check the matches first: shops put unsubscribe links in order emails too. |
| One mailing list | list:(updates.example.com) | Skip the Inbox, Apply the label |
| Calendar invitations | filename:ics | Apply the label: Calendar |
| Tool notifications | from:(notifications@github.com) | Mark as read, Apply the label |
| Mail sent to a plus address | to:(you+shopping@gmail.com) | Apply the label: Shopping. The Gmail alias generator makes these addresses. |
| Never lose the boss | from:(manager@example.com) | Star it, Never send it to Spam, Always mark it as important |
| Find space hogs (one-off) | has:attachment larger:10M older_than:1y | Run as a search, not a filter. Delete or download what you don't need. |
Two habits keep a filter set manageable. Name labels after what you'll do with the mail (Receipts, Reading, Waiting) rather than who sent it, and combine senders into one filter with OR instead of making one filter per sender.
What a Gmail filter can't do
- It matches words, not meaning. A filter for "can you send" misses "could you share", "please forward" and every other way of asking. Requests, promises and deadlines are phrased too many ways for a string to catch.
- It can't see the conversation's state. There is no operator for "I haven't replied yet" or "they promised this by Friday", so a filter can't build a waiting-on list.
- Forwarding needs setup first. The address has to be added and verified under Forwarding and POP/IMAP before a filter can forward to it, a forwarding filter only affects new messages, and forwarding to several addresses takes one filter per address (Google Help).
- Exclusions work per message, not per thread. Google notes that a conversation can still appear in a search like -is:starred if any one message in it is unstarred.
- There's a ceiling. Gmail's API documentation caps an account at 1,000 filters (Google for Developers).
The first two are the gap NeatMail fills. It reads each email for what it asks or promises, files commitments under a Follow up label, and labels the rest by meaning, so the rules you write here can stay simple. To try that on a single thread first, the email promise extractor shows what a filter would have missed.
Back up and move your filters
Gmail can export every filter you have as one XML file. Open Settings → See all settings → Filters and Blocked Addresses, tick the filters you want, and click Export at the bottom. To load them into another account, use Import filters on the same tab, choose the file, and click Create filters (Google Help). It's worth doing before you move from a personal Gmail to Google Workspace, or before deleting a filter you might want back.
Frequently asked questions
- How do I create a filter in Gmail?
- Paste the generated query into Gmail's search bar, click the Show search options icon at the right of the bar, then click Create filter at the bottom of the panel. Pick actions such as apply a label, skip the inbox, mark as read, star or forward, and click Create filter again. It then runs on every new message that matches.
- What search operators does Gmail support?
- Common operators include from:, to:, subject:, has:attachment, filename:, list:, deliveredto:, larger: and smaller: for size, older_than: and newer_than: for dates, and OR, minus and parentheses for combining terms. Date and status operators such as older_than: or is:unread are only useful for cleaning up existing mail, because a filter checks each message as it arrives.
- Can a filter apply to existing emails?
- Yes. When you create a filter, Gmail offers a checkbox to also apply it to matching conversations already in your mailbox, so you can clean up old mail as well as automate future messages.
- How many filters can Gmail have?
- Gmail's API documentation caps an account at 1,000 filters. If you get close, combine senders or keywords with OR and parentheses into fewer, broader filters.
- Can a Gmail filter forward email automatically?
- Yes, once the forwarding address is added and verified under Settings, Forwarding and POP/IMAP. A forwarding filter only affects new messages, not mail already in your account, and to forward to several addresses you need one filter per address.
- How do I export or back up my Gmail filters?
- Open Settings, See all settings, Filters and Blocked Addresses, tick the filters you want and click Export. Gmail downloads them as an XML file, which you can load into another account with Import filters on the same tab.
Related tools
Still doing this by hand? NeatMail runs it for you, on every email, inside Gmail and Outlook.
Start free