Disclosure: ShepHouse is an AI-operated software studio with a human owner. An AI agent wrote these guides and ran every code sample. We sell one of the hosted options mentioned below (a paid Apify Actor). Free options come first.
Bulk phone number validation and E.164 formatting
Published by ShepHouse, an AI-operated venture. This guide was written with AI assistance. Links to ShepHouse products are labeled as paid.
Short answer: use Google's libphonenumber (phonenumbers in Python). Parse each number with a default country, keep the ones where is_valid_number is true, and store them as E.164 (+14155550123). This checks the format and numbering plan. It does not tell you whether the line is currently live.
Python (free)
# pip install phonenumbers
import csv, phonenumbers as pn
from phonenumbers import PhoneNumberFormat as F, number_type, PhoneNumberType as T
rows = []
for r in csv.DictReader(open("contacts.csv")):
try:
n = pn.parse(r["phone"], "US") # default region for numbers without +
ok = pn.is_valid_number(n)
rows.append({**r, "e164": pn.format_number(n, F.E164) if ok else "",
"valid": ok, "mobile": number_type(n) == T.MOBILE})
except pn.NumberParseException:
rows.append({**r, "e164": "", "valid": False, "mobile": False})
w = csv.DictWriter(open("clean.csv", "w", newline=""), fieldnames=rows[0].keys())
w.writeheader(); w.writerows(rows)
Pitfalls
- Excel destroys numbers. It drops leading zeros and turns long numbers into
4.15E+09. Import the column as text. - Default region matters. Without a
+,020 7946 0958is valid for GB but invalid for US. - US numbers can't tell you mobile vs. fixed. US numbering doesn't separate them, so libphonenumber returns
FIXED_LINE_OR_MOBILE. - Valid doesn't mean reachable. Checking whether a line is live needs a paid carrier lookup (HLR/LRN).
- Deduplicate after formatting.
(415) 555-0123and+1 415 555 0123are the same number.
No-code / API option
The ShepHouse Phone Number Validator & Formatter on Apify is a paid ShepHouse product. It runs libphonenumber at scale: paste a list or upload a CSV, and get E.164, national and international formats, the type, the region and validity. It costs $0.0008 per number and runs offline, so your numbers aren't sent to any third-party lookup. Export to CSV or JSON, or call it from the Apify API.