A lead list can look fine until you import it. One email has spaces around it. Another appears twice with different capital letters. Two rows have no usable address. If you send everything straight to your CRM, you create extra work.
Quick answer: This n8n lead email cleanup workflow trims spaces, lowercases addresses and flags duplicates within one incoming batch. It keeps problem rows for review instead of deleting them. Download the demo, import it into a new workflow and run the five sample leads. You should see two ready records, one duplicate and two review records.
Tested on 6 October 2026: n8n Cloud 2.42.3. The imported workflow completed successfully with the supplied five-record sample. No credentials, AI model, paid API or external connection is used.
Download the n8n workflow
Download the free workflow bundle (ZIP). Extract it first. The bundle contains the importable JSON, a short README and a separate copy of the cleanup code. You do not need to write the code yourself.
The demo is useful if you collect leads from forms, spreadsheets or event lists. Start here before adding a CRM action. It is a small data-cleaning example, not a complete lead collection system.
What the four nodes do
Run demo starts the workflow when you click Execute workflow. Sample leads creates five fictional contacts. Clean and flag emails checks each address and adds a status and reason. Check demo results verifies the expected sample output.

1. Import the demo into a new workflow
Create a new workflow in n8n. Open the workflow’s More actions menu, choose Import, then From file. Select n8n-lead-email-cleanup.json from the extracted ZIP. These are the menu labels in the version we tested; older versions may show Import from File directly.
Import into a new workflow so you can follow the example on its own. You should see four connected nodes. There are no credential fields to fill in.
2. Run the five sample leads
Click Execute workflow. Open Check demo results and view its output. The result should say PASS, with five input records, two ready, one duplicate and two review.

Alex’s first address starts as “ Alex@Cedar.example ”. The cleanup step changes it to “alex@cedar.example” and marks it ready. Alex’s second row uses the same address, so it becomes a duplicate. Morgan has an empty address and Sam has “not-an-email”, so both need review. Taylor’s address becomes the second ready record.
The addresses end in .example because the sample is fictional. A ready status only means the row passed this demo’s checks. It does not mean the address belongs to a real person.
3. Inspect the cleaned rows
Open Clean and flag emails. Its output still contains all five rows. Each row keeps its lead ID and name, plus the original email, cleaned email, status and reason. Keeping the original value makes it easier to understand what changed.
The three statuses are simple: ready means the first address in this batch that passes the format check; duplicate means a valid address already appeared in the batch; review means the address is missing or has an obvious format problem.
All Code nodes use JavaScript and Run Once for All Items. The cleanup step needs to see the whole incoming list so it can compare addresses. Switching it to Run Once for Each Item would not match this example.
4. Replace the sample with your own source
Once the demo works, duplicate it before making changes. Replace Sample leads with your form, spreadsheet or another source node. Make sure each incoming item has an email field. If your source calls it “Email Address”, map that field to email first.
Remove Check demo results from your working copy. It expects the exact five supplied records and will correctly fail when you change the sample. It is a test step, not a production reporting step.
After Clean and flag emails, add an IF or Filter node that sends only rows with status equal to ready towards your next action. Send review rows to a review list. Keep duplicate rows available if you need an audit trail. The download does not include these live actions.
Before you connect a CRM
This demo forgets its duplicate history at the end of each run. If you run it again, Alex’s first row will be ready again. That is expected. The check only compares records in the current batch.
For duplicates across separate submissions, add a lookup or an upsert in your CRM using the normalized email as a key. If two runs can arrive at the same time, use a unique constraint or another atomic operation in the destination. A lookup followed by a separate create can still race.
Be careful with the field you use as a key. A shared company inbox can belong to several contacts. Decide whether your business treats that as one contact before using email alone.
Common problems and limits
Every row needs review: Check the input field name and confirm email is a text value. Missing and non-text values go to review. The workflow does not guess an address.
The second run still has ready rows: This is a batch check, not persistent storage. Add a CRM lookup or upsert if you need to remember earlier runs.
The final node fails after editing the sample: Check demo results only verifies the supplied sample. Remove or rewrite that test when changing the input.
An address passes but bounces: The format check only catches obvious problems. It does not check DNS, mailbox existence, consent or deliverability.
Two addresses differ only by a plus tag or a dot: This workflow does not rewrite those addresses. Provider rules differ. It also lowercases the whole address as a practical CRM convention; review that choice if you must preserve case-sensitive local parts.
Frequently asked questions
Does this delete duplicate leads? No. It flags them and keeps every row so you can decide what to do next.
Can I use it on n8n Cloud? Yes. The supplied demo ran on n8n Cloud 2.42.3. It uses standard nodes and JavaScript without external libraries.
Does it need an AI model? No. These checks are straightforward rules, so an AI call would add cost without helping this example.
Is this ready to write contacts to my CRM? The cleanup demo is tested. CRM mapping, filtering, persistent duplicate checks and live writes still need to be configured and tested for your destination.
Build the next step
For more examples, visit the n8n workflows start page. If your workflow needs failure alerts, read our n8n error workflow guide. If an AI step changes important data, add a human approval step.
The Code node mode is documented in n8n’s official Code node guide. The screenshots above show our actual demo run.
Want the next practical workflow guide? Join the OperantSolo newsletter.

