Gmail filter generator Plain rules in, one file Gmail imports.

mailFilters.xml

2 filters, ready to import

  1. Receipts

    Catches
    Mail with receipt, invoice or order confirmation in the subject.
    Then
    Label Receipts and skip the inbox.
  2. Newsletters

    Catches
    Mail with unsubscribe.
    Then
    Label Newsletters, skip the inbox and mark as read.

Import it into Gmail

  1. Download mailFilters.xml from the card above.
  2. On a computer, open Filters and Blocked Addresses in Gmail's settings. Gmail's app can't import filters.
  3. Click Import filters at the bottom, choose the file and click Open file.
  4. Tick Apply new filters to existing email to sort what's already there, then click Create filters.
The whole file2 filters
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
  <title>Mail Filters</title>
  <id>tag:mail.google.com,2008:filters:</id>
  <updated>2026-11-13T00:00:00Z</updated>
  <author>
    <name>Construct Computer</name>
    <email>hello@construct.computer</email>
  </author>
  <!-- Receipts -->
  <entry>
    <category term="filter"></category>
    <title>Mail Filter</title>
    <content></content>
    <apps:property name="subject" value="receipt OR invoice OR &quot;order confirmation&quot;"/>
    <apps:property name="shouldArchive" value="true"/>
    <apps:property name="label" value="Receipts"/>
  </entry>
  <!-- Newsletters -->
  <entry>
    <category term="filter"></category>
    <title>Mail Filter</title>
    <content></content>
    <apps:property name="hasTheWord" value="unsubscribe"/>
    <apps:property name="shouldArchive" value="true"/>
    <apps:property name="shouldMarkAsRead" value="true"/>
    <apps:property name="label" value="Newsletters"/>
  </entry>
</feed>

Gmail search operators

OperatorWhat it findsExampleIn a filter
from:The sender, by address or domainfrom:@acme.comYes
to:A recipientto:you+receipts@gmail.comYes
cc: and bcc:Someone copied incc:team@acme.comYes
deliveredto:The address it was delivered todeliveredto:you+news@gmail.comYes
subject:Words in the subject linesubject:invoiceYes
OR, or { }Either term, with OR in capitalsfrom:(amy@acme.com OR dan@acme.com)Yes
Minus (-)Leaves out mail with the wordinvoice -paidYes
" "An exact phrase"order confirmation"Yes
( )Groups termssubject:(receipt OR invoice)Yes
has:attachmentMail with any attachmenthas:attachment from:@bank.comYes
filename:An attachment's name or typefilename:pdfYes
larger: and smaller:Size, with M for megabyteslarger:10MYes
list:Mail from a mailing listlist:news@acme.comYes
label:, in: and is:Where mail sits or what's been done to itis:unreadSearch only
older_than: and newer_than:Age, in d, m or yolder_than:1ySearch 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 doesIn Gmail's filter formIn the file
Matches the senderFromfrom
Matches a recipientToto
Matches the subjectSubjectsubject
Matches words, phrases and operatorsHas the wordshasTheWord
Leaves out wordsDoesn't havedoesNotHaveTheWord
Needs an attachmentHas attachmenthasAttachment
Matches sizeSize, greater or less thansize, sizeOperator (s_sl or s_ss) and sizeUnit (s_smb, s_skb or s_sb)
Skips the inboxSkip the Inbox (Archive it)shouldArchive
Marks it readMark as readshouldMarkAsRead
Stars itStar itshouldStar
Labels itApply the labellabel, with a slash for a nested label
Forwards itForward it toforwardTo
Deletes itDelete itshouldTrash
Keeps it out of spamNever send it to SpamshouldNeverSpam
Sets importanceAlways, or Never, mark it as importantshouldAlwaysMarkAsImportant or shouldNeverMarkAsImportant
Moves it to a tabCategorize assmartLabelToApply: ^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=1

Questions

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 Construct

More free tools

Every tool