Gmail filter generator Plain rules in, one file Gmail imports.
Gmail search operators
| Operator | What it finds | Example | In a filter |
|---|---|---|---|
| from: | The sender, by address or domain | from:@acme.com | Yes |
| to: | A recipient | to:you+receipts@gmail.com | Yes |
| cc: and bcc: | Someone copied in | cc:team@acme.com | Yes |
| deliveredto: | The address it was delivered to | deliveredto:you+news@gmail.com | Yes |
| subject: | Words in the subject line | subject:invoice | Yes |
| OR, or { } | Either term, with OR in capitals | from:(amy@acme.com OR dan@acme.com) | Yes |
| Minus (-) | Leaves out mail with the word | invoice -paid | Yes |
| " " | An exact phrase | "order confirmation" | Yes |
| ( ) | Groups terms | subject:(receipt OR invoice) | Yes |
| has:attachment | Mail with any attachment | has:attachment from:@bank.com | Yes |
| filename: | An attachment's name or type | filename:pdf | Yes |
| larger: and smaller: | Size, with M for megabytes | larger:10M | Yes |
| list: | Mail from a mailing list | list:news@acme.com | Yes |
| label:, in: and is: | Where mail sits or what's been done to it | is:unread | Search only |
| older_than: and newer_than: | Age, in d, m or y | older_than:1y | Search only |
From Google's list of Gmail search operators, checked on 14 November 2026. A filter acts on mail as it arrives, so an operator about where mail sits, what's been done to it or how old it is only helps in search.
The mailFilters.xml format
| What it does | In Gmail's filter form | In the file |
|---|---|---|
| Matches the sender | From | from |
| Matches a recipient | To | to |
| Matches the subject | Subject | subject |
| Matches words, phrases and operators | Has the words | hasTheWord |
| Leaves out words | Doesn't have | doesNotHaveTheWord |
| Needs an attachment | Has attachment | hasAttachment |
| Matches size | Size, greater or less than | size, sizeOperator (s_sl or s_ss) and sizeUnit (s_smb, s_skb or s_sb) |
| Skips the inbox | Skip the Inbox (Archive it) | shouldArchive |
| Marks it read | Mark as read | shouldMarkAsRead |
| Stars it | Star it | shouldStar |
| Labels it | Apply the label | label, with a slash for a nested label |
| Forwards it | Forward it to | forwardTo |
| Deletes it | Delete it | shouldTrash |
| Keeps it out of spam | Never send it to Spam | shouldNeverSpam |
| Sets importance | Always, or Never, mark it as important | shouldAlwaysMarkAsImportant or shouldNeverMarkAsImportant |
| Moves it to a tab | Categorize as | smartLabelToApply: ^smartlabel_personal, social, promo, notification, group or receipt |
Google doesn't publish the format. These are the names Gmail writes when it exports filters, which open-source tools like gmailctl use too. Purchases, as ^smartlabel_receipt, is the newest, added to gmailctl in May 2026.
Make filters from an agent or a script
Fetch this page with a filter's words, like from=, subject=, has=, label= and archive=1, and it answers in Markdown: each filter in words with its Gmail search, the file, and how to import it. Number the words for more than one filter, like 1.from= and 2.from=. Add &format=json for JSON, or &format=xml for mailFilters.xml itself, which a browser downloads. In a browser with WebMCP, the page offers the same as its make_gmail_filters tool.
https://construct.computer/tools/gmail-filter-generator/?from=@acme.com&label=Clients&archive=1Questions
On a computer, click Show search options at the right of Gmail's search box, fill in who the mail is from or what it says, then click Create filter, tick what Gmail should do and click Create filter again. To make several at once, write them here and import the file. Google's steps.
Open Gmail on a computer, click the gear and choose See all settings. On Filters and Blocked Addresses, click Import filters at the bottom, choose mailFilters.xml and click Open file. Gmail lists the filters it found: tick Apply new filters to existing email to sort mail that's already there, then click Create filters. Google's steps.
In Gmail's settings, on Filters and Blocked Addresses, tick the filters you want, or Select all, and click Export. Gmail saves them as mailFilters.xml. Open that file here to read every filter in plain words, change them and make a new file to import.
Type the addresses in From with commas between them, and the generator joins them with OR, the way Gmail needs: from:(amy@acme.com OR dan@acme.com). Gmail also reads {amy@acme.com dan@acme.com} as either one. For everyone at a company, type the domain on its own, like @acme.com. Gmail has no wildcard like *, and the domain does the same job.
Only if you ask it to, since a filter acts on mail as it arrives. When you import the file, tick Apply new filters to existing email. For a filter already in Gmail, click edit, then Continue, tick Also apply filter to matching conversations and click Update filter. Gmail skips mail in Spam and Trash, and forwarding only ever acts on new mail.
Make a filter that matches them and ticks Delete it. New mail that matches goes straight to Trash, which Gmail empties after 30 days, and Apply to existing email clears what's already there once. A filter can't delete mail as it gets old, since older_than: only works in search: search for older_than:1y and delete the results by hand.
Most often it's one of four things. A filter acts only on mail that arrives after you make it. Operators about where mail sits or its age, like label:, is: and older_than:, never match arriving mail. Mail in Spam and Trash is skipped. And forwarding needs an address you've verified. Click Search Gmail under a filter here to see what it catches before you import it.
Up to 1,000 filters an account, as Google's Gmail API puts it. A filter with many senders joined by OR counts as one, so group senders that get the same treatment. Google on filter limits.
Yes, to an address you've added and verified first, in Settings, Forwarding and POP/IMAP, Add a forwarding address. Add it there before you import a filter that forwards, and expect it to act on new mail only. Google on forwarding.
Yes. Gmail calls them filters, and Google's help calls them rules to filter your emails, the word Outlook uses. Each one is a search that Gmail runs on every new email, with what to do when it matches.
Not in the Gmail app, which can't create, edit or import filters. You can build the file on your phone here, then import it from Gmail in a browser on a computer.
No. A filter checks the sender, the subject, the words and a few facts like size and attachments, so a client asking for a quote and a sales pitch with the same words land in the same place. Telling them apart takes something that reads each email.
Not from this page. The filters and the file are made in your browser, and a file you open is read there too. A GET with a filter's words, the way agents make filters, carries them in its address, which our request logs keep for up to 7 days.
Filters go by words, so a client's question and a cold pitch that share them land in one label. In Construct, the Inbox Manager reads each new email, sorts it by what it needs from you and drafts the replies for you to check.
Try it in ConstructMore free tools
- Link preview checkerSee how your link looks in iMessage, WhatsApp, X, Discord, Slack, Telegram, LinkedIn and Facebook. A free Open Graph checker with a score and the tags to fix.
- Domain authority checkerCheck any site's domain authority free: Ahrefs DR4 beside DR3, domain age, Tranco rank and Wikipedia links, five sites at once, with Moz DA a click away.
- MCP config generatorMake MCP config for Claude Code, Cursor, VS Code, Codex and 11 more from one server URL or command, checked live, with install links and README buttons.