Free tool
Gmail mass delete builder
Pick where to look, how old and how big the mail should be, and what to keep safe. You get one Gmail search to paste in, a plain description of what it finds, and the steps to delete the matches yourself.
Runs in your browser. Nothing you enter is sent to InboxNight.
- Choose at least one filter. With nothing narrowing the search, the query would match almost all of your mail.
Gmail search query
Choose at least one filter to see the query.
Delete the matches in Gmail on a computer
- Open Gmail and paste the query into the search box, or use the open button above. Press Enter.
- Look through the results. This page has not touched your mail, so nothing is deleted yet.
- Tick the Select box above the list. A notice shows how many conversations on the page are selected.
- Click the link in that notice to select every conversation that matches, not only the page.
- Click Delete.
Deleted mail moves to Trash. It stays there for up to 30 days and can be moved back until then. Mail in Trash and Spam still counts against your Google storage until it is removed for good, so to free the space, open Trash and click Empty Trash now.
How to use it
- Choose all mail or the inbox only, then tick the inbox tabs to include. Leave every tab unticked to search all four.
- Pick a minimum age and a minimum size. Keep the two protection boxes ticked unless you want starred or important mail in the results.
- Open the extra filters if you need a received-before date, read or unread mail only, certain senders, an exact phrase, or only mail with attachments.
- Copy the query, or click the open button, and run the search in Gmail. Read through the results before you delete anything.
- In Gmail on a computer, tick the Select box above the list, click the link that selects every matching conversation, then click Delete.
How the query is put together
The tool adds one search term for each choice you make, always in the same order, and leaves out any choice you did not make.
- Inbox only adds in:inbox. All mail adds nothing, and Gmail leaves Spam and Trash out of a search unless the search asks for them with in:anywhere.
- Ticked tabs become category: terms. One tab is a single term and several tabs become a braced any-of group such as {category:promotions category:social}.
- With no tab ticked, all four tabs (Promotions, Social, Updates, Forums) are searched. The Primary tab is never searched.
- Age becomes older_than: with 1m, 6m, 1y, 2y or 5y. Size becomes larger: with 5M, 10M or 25M.
- A received-before date becomes before: in the YYYY/MM/DD form that Gmail reads.
- Read or unread only becomes is:read or is:unread.
- Senders become from: terms. Several senders are grouped in braces so that mail from any one of them matches.
- An exact phrase goes in quotes, so Gmail looks for those words together and in that order.
- Only with attachments adds has:attachment.
- The two protections come last as -is:starred and -is:important, and both are on until you switch them off.
- If nothing narrows the search, the tool shows a warning and no query, because the query would match almost everything.
What the code works out for you
These parts are fixed by code and do not depend on guesswork.
- The order of the terms is always: place, tabs, age, size, received-before date, read state, senders, phrase, attachments, protections.
- Tabs are written in Gmail's own tab order, so the query is the same whichever tab you ticked first.
- Senders are lower-cased, split on commas, semicolons and spaces, and repeats are removed. A leading @ is removed and an address inside angle brackets is used.
- A date is accepted only if it is a real calendar day. Anything else stops the query and tells you.
- Quote marks in the phrase are removed, because Gmail search has no way to put a quote inside a quoted phrase.
- The open-in-Gmail address is https://mail.google.com/mail/u/0/#search/ followed by the whole query, encoded.
What this tool does not do
- It does not connect to your Gmail account, so it cannot count the matches or show you the messages.
- It deletes nothing. You run the search and do the deleting inside Gmail.
- It cannot search the Primary tab by itself. Leave the tab boxes empty and Primary is still left out.
- It cannot match a sender by display name. Gmail's from operator matches an address or a domain, so a name typed into the senders box is set aside with a note.
- It cannot keep a protected message out of a conversation that has other messages in it. Gmail judges conversations, so one starred message beside unstarred ones does not stop the conversation from matching.
- It cannot empty Trash or bring back mail that has been removed for good.
Worked examples
Clear out old promotions
You enter: Marta Okafor at Lumen Studio ticks Promotions and Social, sets the age to older than 2 years, and leaves both protections on.
You get: {category:promotions category:social} older_than:2y -is:starred -is:important
Find the heavy attachments in the inbox
You enter: Devon Ames at Brightline Logistics picks inbox only, older than 1 year, larger than 10 MB, and mail with attachments only.
You get: in:inbox {category:promotions category:social category:updates category:forums} older_than:1y larger:10M has:attachment -is:starred -is:important
Drop unread notifications from two senders
You enter: Priya Raman at Harbor & Pine ticks Updates, sets the age to older than 6 months, picks unread only, and lists two sender addresses.
You get: category:updates older_than:6m is:unread {from:digest@harborpine.example from:updates.cloudnote.example} -is:starred -is:important
Common mistakes
- Selecting only the page. The Select box ticks the conversations on the page you are looking at. Click the link that appears above the list to select every matching conversation, or only that page is deleted.
- Trusting the protections too much. A conversation with one starred message and several plain ones can still match. Scan the results before you delete, or narrow the search further.
- Forgetting Trash. Deleted mail moves to Trash and keeps using your Google storage until it is removed for good. To free the space, empty Trash.
- Typing a sender's name. The from operator wants an address or a domain. Type shop.example or news@shop.example, not the name shown in your inbox.
Questions and answers
Does this tool delete my email?
No. It writes a search query and nothing else. You paste the query into Gmail, check the results and delete there. The tool never signs in and never sees your mail.
What happens to mail after I delete it in Gmail?
It moves to Trash. For up to 30 days you can find it there and move it back to your inbox. After 30 days Gmail removes it for good and it cannot be recovered. You can also delete it from Trash yourself before then.
Will deleting free up storage right away?
Not until Trash is emptied. Google counts Gmail messages and attachments, including Spam and Trash, against your account storage. Open Trash and choose Empty Trash now to clear it, then allow time for the total to update.
Why does the query leave out the Primary tab?
Mass deletes are usually aimed at Promotions, Social, Updates and Forums, where bulk mail collects. The tool never adds the Primary tab, so personal mail there is left alone.
What if I set both an age and a received-before date?
Both go into the query and mail has to match both, so whichever limit is stricter decides. The tool shows a note when you do this.
Do I need to be signed in for the open button to work?
The button opens Gmail in a new tab, and Gmail asks you to sign in if you are not. The search is carried in the address, so the tool itself never handles your login.
Can I use the same query in a filter?
Yes. Gmail lets you create a filter from a search, so you can paste the query into the search options and choose to create a filter from it. Our Gmail filter generator also writes a filter file.
Sources
- Google: Delete messages in Gmail, read 2026-10-19.
- Google: Refine searches in Gmail, read 2026-10-19.
- Google: How your Google storage works, read 2026-10-19.
- Google: Manage your storage in Drive, Gmail & Photos, read 2026-10-19.