Cleaning phone numbers and names
🎯You'll be able to
Normalise Indian phone numbers to E.164 and tidy names, and flag values that can't be fixed safely.
🏠The everyday picture
The same friend can be saved in your phone as "Rahul", "Rahul K" and "rahul kumar office", with three different number formats. When you want to message him, you're not sure which entry is right.
📘What it really is
- People type data in many ways. Common phone number shapes in India:
-
98765 43210,09876543210,+91-98765-43210,919876543210. -
A normalised format makes matching and messaging work. A common choice is E.164:
+919876543210(plus sign, country code, number, no spaces). -
A cleaning rule for Indian mobile numbers:
- remove spaces, dashes and brackets;
- remove a leading
+91,91(when 12 digits) or0(when 11 digits); - check that 10 digits remain and the first is 6, 7, 8 or 9;
-
if valid, store
+91followed by the 10 digits; otherwise send to review. -
Names: trim spaces, collapse double spaces, and tidy capitals carefully. Don't force every name into one pattern: some people use one name, some use initials, and some prefer particular spellings.
-
Clean data once, at the entrance to your system, and keep the original value too, so mistakes can be traced.
📝A worked example
Twenty Sharma Textiles contacts were cleaned:
| Original | Cleaned | Result |
|---|---|---|
98765 43210 |
+919876543210 |
Valid |
09876543210 |
+919876543210 |
Valid; matches the contact above, so a duplicate |
+91-98765-4321 |
— | Only 9 digits after +91: sent to review |
asha VERMA |
Asha Verma |
Spaces and capitals tidied |
K. Lakshmi |
K. Lakshmi |
Left as written |
Cleaning showed two records were the same customer, which the weekly CRM tidy-up project will merge.
🌍Where it's used
- Messaging: WhatsApp and SMS need correct country codes.
- Deduplication: matching contacts across systems.
- Lead imports from ads and events.
- Delivery: couriers reject or delay parcels with bad numbers.
📝Case scenario
A WhatsApp campaign fails for a third of contacts. The numbers were stored as 09876543210, with a leading zero and no country
code, which the messaging API rejects. You add a cleaning step at the point where contacts enter the CRM, clean the existing
records in a one-off run with a report of changes, and send invalid numbers to staff to check.
🖱️Try it
Write 20 messy phone numbers and names (include valid, invalid and duplicate ones). Apply the cleaning rule by hand, then in an n8n step (an expression or Code node; you'll write more code in DA5). Count how many were valid, invalid and duplicates.
⚠️Common mistakes
- Guessing invalid numbers. Sign: a 9-digit number gets a digit added. Fix: return "invalid" and send it to a person.
- Cleaning before checking duplicates in the wrong order. Sign: the same person appears twice in different formats. Fix: clean first, then compare.
🛠️For your project
Make the starter tidyup/clean-phone.js pass all 13 of its tests. Project 3 uses it on 412 contacts.
✅Quick check
What is the E.164 form of the Indian mobile number 09876543210?
Show the answer
+919876543210.
Why keep the original value when cleaning data?
Show the answer
So you can trace and fix mistakes if the cleaning rule turns out to be wrong.
