See llms.txt for all machine-readable content.

Back to Templates

Clean and deduplicate lead lists with Google Sheets and CSV

Quick overview

Clean a messy lead list without AI or paid APIs. Fixes name casing, repairs email typos like gmial.com, checks email syntax, flags free-mail, role and disposable addresses, finds the company domain and merges duplicate people. Each row marked ready or review. Works with Google Sheets, CSV or sample data.

How it works

  1. Cleaner settings picks the source (sample, csv or google_sheets) and holds the file paths, sheet URL, tab names and options.
  2. Read leads: CSV files are read and parsed with a header row, Google Sheets rows are read from your input tab, or Sample messy leads supplies 12 test rows.
  3. Normalize and validate leads (plain JavaScript): maps common column names (Full Name, E-mail, Email Address, Organization, Company URL...) to one schema, keeping unknown columns. Fixes name casing (JOHN SMITH -> John Smith, mary o'brien -> Mary O'Brien, van der Berg, McDonald), drops titles like Dr. and splits full names into first and last. Cleans emails (mailto:, spaces, trailing ;), fixes common domain typos (gmial.com, hotmial.com, yahoo.con...), checks syntax and classifies each address as business, free-mail, role (info@, sales@) or disposable. Takes the company domain from the website column, or from a business email when there is no website.
  4. Merge duplicate leads groups rows that are the same person: same mailbox (case, +tags and Gmail dots ignored), or same name plus company domain or company name. The first row wins and empty fields are filled from its duplicates. Each output row gets lead_status (ready/review), readable issues and fixes, merged_rows, other_emails and a stable dedupe_key.
  5. Write results: CSV mode writes a cleaned CSV file (overwritten each run). Google Sheets mode upserts rows into your output tab on dedupe_key, so re-runs update rows instead of adding duplicates. Sample mode just shows the result in Preview cleaned leads.
  6. Summarize cleaning run returns one item with counts: rows in and out, duplicates merged, ready vs review, email types, emails auto-fixed. If the CSV file is missing, n8n stops with 'No file(s) found'. If the file or sheet has headers but no rows, the run stops with a clear 'No lead rows found' message.

Setup

  1. Import the workflow and click Execute workflow with source = sample to see the output.
  2. CSV: set source = csv, csv_input_path and csv_output_path. The folder must be readable and writable by n8n. On n8n 2.x the default allowed folder is ~/.n8n-files (/home/node/.n8n-files in Docker); other folders need N8N_RESTRICT_FILE_ACCESS_TO.
  3. Google Sheets: set source = google_sheets, paste the sheet URL into google_sheet_url, set input_tab and output_tab, create the empty output tab, and select a Google Sheets credential in both Google Sheets nodes.

Requirements

  • n8n (tested on self-hosted n8n 2.47.7). Uses the Read/Write Files from Disk node version 1.1.
  • For Google Sheets mode: a Google Sheets OAuth2 credential.
  • No AI, no paid APIs, no community nodes.

Customization

  • Add your own free-mail domains (comma separated) to extra_free_mail_domains.
  • Set fix_email_typos to false to leave email domains as typed.
  • Add column-name variants, free-mail, disposable or role lists in the Normalize and validate leads node.
  • Change how duplicates are matched or merged in the Merge duplicate leads node.
  • Change what counts as ready (for example, send role addresses to review) in the lead_status line of Merge duplicate leads.

Additional info

Want AI company research and ICP scoring for your cleaned leads? See the Relaybrook AI Lead Enrichment Pack: https://relaybrook.bytesell.app