Skip to main content
← Back to blog
Phone Number Management5 min read

Phone Number Validation: How to Check If a Number Is Real

You have a phone number. Before you call it, text it, or add it to your CRM, you want to know: is this number actually real?

Phone number validation happens at several levels — from basic format checking to actually verifying the number exists and is active. Here's what each level tells you and how to do it.

Level 1: Format Validation

The most basic check: does this number follow the rules for phone numbers in its country?

What it checks:

  • Correct number of digits for the country (see phone number formats explained for how digit counts vary)
  • Valid country code
  • Valid area code or mobile prefix
  • Proper structure (e.g., US numbers must be 10 digits after the country code)

What it doesn't tell you:

  • Whether the number is actually assigned to someone
  • Whether the number is active
  • Whether it's a mobile or landline

How to do it:

  • Google's libphonenumber — The gold standard. Open-source library available in Java, JavaScript, C++, and Python. It knows the formatting rules for every country.
  • NumSwift — When you paste text into NumSwift, it uses format validation to identify real phone numbers in your text. Numbers that don't match valid patterns are filtered out.
  • Manual — Check the country code, count the digits, verify the area code exists. Error-prone for unfamiliar countries.

Example with libphonenumber (JavaScript):

import { parsePhoneNumber, isValidNumber } from 'libphonenumber-js';

const number = parsePhoneNumber('+14155552671');
console.log(number.isValid()); // true
console.log(number.country); // 'US'
console.log(number.getType()); // 'FIXED_LINE_OR_MOBILE'

Level 2: Number Type Detection

Beyond format, you can determine what kind of number it is:

| Type | Description | Can receive SMS? | Can receive WhatsApp? | | ------------ | -------------- | ---------------- | --------------------- | | Mobile | Cell phone | Yes | Usually | | Fixed line | Landline | Rarely | No | | Toll-free | 1-800 numbers | No | No | | Premium rate | Pay-per-call | No | No | | VoIP | Internet phone | Sometimes | Sometimes | | Shared cost | Split-charge | No | No |

Why this matters:

  • Sending SMS to a landline wastes money (and fails silently with some providers)
  • WhatsApp only works on mobile numbers (and some VoIP numbers)
  • Toll-free and premium rate numbers shouldn't be in your contact list

How to detect type:

  • libphonenumber's getType() method — Free, works offline, but based on number ranges (not 100% accurate for ported numbers)
  • Carrier lookup APIs (Twilio, NumVerify) — More accurate, but cost per lookup

Level 3: Existence Verification

Does this number actually exist and is it in service?

Methods:

HLR Lookup (Home Location Register)

Queries the mobile network to check if a number is registered. Returns:

  • Whether the number exists
  • Which network it's on
  • Whether it's currently reachable (phone on/off)
  • Whether it's been ported to another carrier

Cost: $0.005–$0.05 per lookup depending on provider.

Providers: Twilio Lookup, NumVerify, HLR Lookups, Infobip.

Ping/Flash Call

Initiates a call that disconnects immediately. If the number rings, it exists. If you get "number not in service," it doesn't.

Limitations: Intrusive, may show a missed call, doesn't work for all carriers.

WhatsApp Registration Check

If you specifically need to know whether a number is on WhatsApp:

  1. Save the number as a contact
  2. Open WhatsApp → New Chat
  3. If the contact appears with a WhatsApp profile, they're registered

Or use NumSwift to open a wa.me link — if WhatsApp shows the chat screen, the number is registered. If it shows an error, it's not.

Level 4: Identity Verification (KYC)

For businesses that need to verify the number belongs to a specific person:

  • OTP (One-Time Password) — Send a code via SMS, user enters it. Proves they have access to the phone.
  • Voice verification — Automated call reads a code. Works for landlines too.
  • SIM swap detection — Check if the SIM was recently changed (fraud indicator).

This level is typically for financial services, account security, and regulatory compliance.

Free vs Paid Validation

Free Methods

| Method | What it validates | Accuracy | | ----------------------------- | -------------------------- | ------------------------- | | Format check (libphonenumber) | Structure, length, country | High for format | | Manual country code lookup | Basic validity | Depends on your knowledge | | WhatsApp registration check | WhatsApp presence | High for WhatsApp users | | NumSwift extraction | Format + country detection | High for format |

Paid Methods

| Method | What it validates | Cost per lookup | | ----------------------------- | -------------------------------- | ---------------------- | | HLR Lookup | Existence, carrier, reachability | $0.005–$0.05 | | Carrier Lookup (Twilio) | Carrier, type, country | $0.005 | | Full verification (NumVerify) | Format, carrier, line type | $0.01–$0.05 | | OTP verification | Ownership | $0.01–$0.10 (SMS cost) |

Validation for Common Use Cases

"I want to message someone on WhatsApp"

You need: Format validation + WhatsApp registration check.

Quickest approach: Paste the number into NumSwift, click the WhatsApp button. If the chat opens, the number is valid and on WhatsApp. No API calls needed.

"I'm importing contacts into a CRM"

You need: Format validation + type detection (filter out landlines if you'll be sending SMS).

Use libphonenumber to validate and classify each number during import. Reject numbers that fail format validation. A phone number validator can automate this check before you commit records to your CRM.

"I'm building an SMS campaign"

You need: Format validation + type detection + HLR lookup.

Sending SMS to invalid numbers costs money and hurts your sender reputation. An HLR lookup before sending can save 10-20% on messaging costs by filtering dead numbers.

"I'm verifying a user's identity"

You need: OTP verification.

Send a 6-digit code via SMS. User enters the code to prove they control the phone. This is the standard for account registration and 2FA.

Common Validation Mistakes

  1. Validating format only. A correctly formatted number can still be unassigned. Format validation catches typos but not fake numbers.

  2. Assuming all valid numbers are mobile. Landlines pass format validation but can't receive SMS or use WhatsApp.

  3. Not handling country-specific rules. Some countries have variable-length numbers (like Germany). Some require keeping the leading zero (Italy). For a full breakdown of these edge cases, see our country code reference. Don't write your own validation — use a library.

  4. Validating once and never again. Numbers get recycled, deactivated, and ported. Validate periodically if you're maintaining a contact database.

  5. Over-validating. For a quick WhatsApp message, format validation is enough. Don't pay for HLR lookups when you just need to send one message.

Related Guides

Bottom Line

Match your validation level to your use case. For quick WhatsApp messaging, format validation is enough — NumSwift handles this automatically when extracting numbers. For business systems handling thousands of numbers, invest in HLR lookups and type detection. For identity verification, use OTP. Don't over-engineer it, but don't skip it either.