Latenode

Gmail inbox cleanup

This template runs on a schedule, finds Gmail messages that match a query you define, and lets JavaScript drop anything on your keep-list.

Gmail then removes the Inbox label to archive, or adds Trash when you are ready to delete. Connect Gmail, test the query in Gmail first, and start with archive until you trust the rules.

Updated Sep 16, 2026Est. run: 9sEst. cost: $0.0006
How Latenode estimates time and cost

Latenode bills workflow runtime in CPU seconds. The first 10,000 CPU seconds are free each month, then usage follows pay-as-you-go CPU-second pricing. Plug-and-Play (PnP) AI nodes are billed separately—each PnP token is $1 USD, charged pay-as-you-go at vendor cost plus a small processing fee, with no API keys required.

Full pricing — how CPU seconds work →

Workflow preview

What this template does

  • Clears matching Gmail on a schedule
  • Lets you review rules in JavaScript before mail moves
  • Archives by removing Inbox, or adds Trash when you are ready
  • Uses the Gmail connection for search and labels

How it works

1
Trigger

Run on a schedule

The scenario starts on the cadence you set, for example nightly.

2
Action

Find matching mail

Gmail returns messages for the search query you paste, such as sender, subject, or older than a date.

3
Logic

Apply your keep-list

JavaScript drops messages from senders or subjects you want to keep.

4
Action

Archive or trash

Gmail removes the Inbox label to archive, or adds Trash for messages you are ready to delete.

Setup guide

1

Connect Gmail

Add a Gmail connection with permission to read and modify mail in the inbox you want to clean.

2

Test the search query

Paste the same query into Gmail first and check the results. Then put that query on the Find Email step.

3

Set keep-list rules

In JavaScript, list senders or subjects that must stay. Start by removing the Inbox label so mail leaves the inbox without going to Trash.

4

Set the schedule

Run nightly or hourly. Review a few archived threads before you switch the last step to Trash.

Requirements

A Gmail account Latenode can search and label
A search query you have already tested in Gmail
A written keep-list of senders or subjects that must stay

FAQ

Common questions about this template

Each run uses credits on your Latenode plan. We charge for processing time (1 credit = 30 seconds). Your actual cost depends on your plan and how long the run takes. See pricing plans for plans and how credits work.