email-filter-builder

Generate email filters from a declarative spec, and keep Gmail in sync with it.

email-filter-builder is a free, open-source command-line tool. You describe your mail rules once, in a plain JavaScript file, and it produces filters for more than one mail provider from that single source: a Sieve script for ProtonMail, and filters for Gmail.

What it does

Why the sync exists

Gmail's filter import only skips entries that match an existing filter exactly. Re-importing an edited rule leaves the old filter live alongside the new one, and Gmail applies every matching filter. The sync avoids this by diffing: filters that already match are left untouched, ones that no longer belong are removed, and only genuinely new filters are created. Running it twice in a row makes no changes the second time.

Running it

node bin.js filters.js          # write Sieve scripts and a Gmail import file
node sync.js filters.js         # show what would change in Gmail
node sync.js filters.js --apply # make those changes

The sync previews its plan by default and writes nothing without --apply.

Your data

The tool runs on your own computer and talks only to Google. It reads and writes your Gmail filters and labels, and reads your email address to show which account it is about to modify. It does not read your messages. Nothing is sent anywhere else. See the privacy policy for the details.

Source

The full source is public at github.com/raineorshine/email-filter-builder.