Phone number validation in code
A common starting point for developers is a regex like ^\+?[1-9]\d{1,14}$. This passes most E.164 inputs and is a useful client-side gate but it is not a real validator. It accepts impossible country codes (+999999999999999), accepts NANP test numbers like +15555555555, rejects valid short codes, and tells you nothing about line type. Use regex to reject obvious garbage on the client; use a numbering-plan library or this tool's API for real validation before persistence or SMS.
JavaScript libphonenumber-js
import { parsePhoneNumberFromString } from 'libphonenumber-js'
const phone = parsePhoneNumberFromString('+14155552671')
phone.isValid() // true
phone.getType() // 'FIXED_LINE_OR_MOBILE'
phone.formatInternational() // '+1 415 555 2671'
phone.formatNational() // '(415) 555-2671'
phone.getURI() // 'tel:+14155552671'
Python phonenumbers
import phonenumbers
from phonenumbers import PhoneNumberFormat
p = phonenumbers.parse('+14155552671', None)
phonenumbers.is_valid_number(p) # True
phonenumbers.number_type(p) # 1 (mobile / fixed)
phonenumbers.format_number(p, PhoneNumberFormat.E164) # '+14155552671'
phonenumbers.format_number(p, PhoneNumberFormat.RFC3966) # 'tel:+1-415-555-2671'
PHP giggsey/libphonenumber-for-php
use libphonenumber\PhoneNumberUtil;
use libphonenumber\PhoneNumberFormat;
$util = PhoneNumberUtil::getInstance();
$proto = $util->parse('+14155552671', 'US');
$util->isValidNumber($proto); // true
$util->getNumberType($proto); // FIXED_LINE | MOBILE
$util->format($proto, PhoneNumberFormat::E164); // '+14155552671'
Java libphonenumber
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
Phonenumber.PhoneNumber p = util.parse("+14155552671", "US");
util.isValidNumber(p); // true
util.format(p, PhoneNumberUtil.PhoneNumberFormat.E164); // "+14155552671"
HTTP this tool's API
curl -X POST https://www.whoseno.com/tools/phone-number-validator/api.php \
-H 'Referer: https://www.whoseno.com/tools/phone-number-validator/' \
-d 'number=%2B14155552671&default_region=US'
// { "success": true, "valid": true, "country": { "iso2": "US", "name": "United States",
// "calling_code": "1", "flag_emoji": "🇺🇸" }, "type": "FIXED_LINE",
// "formats": { "e164": "+14155552671", "international": "+1 (415) 555-2671",
// "national": "(415) 555-2671", "rfc3966": "tel:+14155552671" }, ... }
Whichever path you take, store the E.164 form in your database. Render the international or national form when you display it.
Validation vs. verification vs. lookup
These three terms get used interchangeably and cost very different amounts of money and time. Pick the right one for your use case.
| Operation | What it tells you | Cost | Latency | Privacy footprint |
| Structural validation | Is the number plausible per the country plan? | Free | Sub-second | None |
| HLR / carrier lookup | Is the number assigned, ported, or roaming, and which operator owns it? | $0.005–0.02 | 200 ms – 2 s | Visible to the operator |
| Verification (SMS / call OTP) | Does the user have access to the number right now? | $0.04–0.40 | Seconds | User receives a real message |
| Reverse lookup | Who is associated with the number? | Varies | Varies | Public-record / community data |
This tool performs structural validation only. If you need carrier-level information for SMS routing decisions, pair it with an HLR provider. If you need proof-of-possession for signup or password reset, use a verification provider that sends a code. If you need to know who a number belongs to, use the WhoseNo reverse lookup.
Common validation errors and how to fix them
- The leading zero gets stripped. A user types
0300 1234567 (Pakistan), client code strips non-digits and casts to integer, the leading zero disappears. Always treat phone numbers as strings, never as integers.
- The wrong country is assumed. A US-based form defaults to US for every visitor. A UK customer types
+44 20 7946 0958 but the parser drops the + and treats it as US, returning invalid. Always honor the explicit + / 00 prefix and override the default region.
- Vanity letters are not converted.
1-800-FLOWERS is 1-800-3569377 after letter conversion. If your validator does not include a letter-to-digit conversion table, vanity numbers fail.
- Extensions are appended.
+1 415 555 2671 ext 142 or …x142 or …#142. The extension is not part of the dialable number strip it (and store separately) before validation.
- Mobile-number portability invalidates carrier guesses. A number originally allocated to T-Mobile may now be served by Verizon or a small MVNO. Prefix-based carrier lookup is approximate for any ported number; only HLR returns the live operator.
- The number is "possible" but not "valid". Total length fits the country, but leading digits are not in any allocated range. Usually a typo, sometimes a reserved test range
555-01XX in NANP, 070 0 personal-numbering in the UK.
- The user pasted a string with hidden Unicode. Some keyboards insert non-breaking spaces, RTL marks, or zero-width joiners. Strip everything except
0-9, +, *, # and (for vanity) A-Z before validating.
Phone number normalization workflow
For teams cleaning a CRM, lead list, or user database, run every phone number through this pipeline before insert or update.
- Trim outer whitespace.
- Strip all characters except digits,
+, *, #, and (for vanity conversion) letters.
- Convert vanity letters to digits using the standard ITU keypad mapping.
- Detect country from the leading
+ / 00 if present, else fall back to the row's billing country or locale.
- Validate structurally with this tool's API or a numbering-plan library.
- Store the canonical E.164 in a single column (
phone_e164).
- Optionally store the line type, country, and original input alongside, but do not rely on the original input as the authoritative form.
- On display, format from the E.164 column to international or national style depending on whether the viewer is in the same country as the number.
This pipeline catches the vast majority of formatting issues that cause SMS deliverability failures, broken click-to-call links, and duplicate contact records.
Use cases by role
- Developers building signup forms, contact imports, or click-to-call links. Validate on the client for instant feedback, validate again on the server before persistence, and store E.164.
- Marketers and growth teams cleaning lead lists before pushing to an SMS, autodialer, or WhatsApp Business platform. Carrier penalties for sending to invalid numbers are real and growing.
- Customer support agents verifying a caller-ID number from a ticket before calling back. The line type tells you whether the original ticket came from a mobile, a landline, or a VoIP number context that informs how you respond.
- Operations and trust & safety checking signup phone numbers against suspicious patterns: premium-rate numbers, sequential test ranges, recently-allocated mobile prefixes that overlap with known fraud rings.
- Researchers and analysts sanity-checking telephony datasets (call-detail records, SMS traffic logs, scam-report archives) before analysis. Bad numbers in, bad insights out.
- Webmasters and CMS owners generating
tel: click-to-call links from a marketing site or knowledge base the tool emits the RFC3966 form ready to drop into an <a href>.
Phone numbers as personal data
Phone numbers are personal data under the EU GDPR, the UK GDPR, the California CCPA / CPRA, Brazil's LGPD, India's DPDP Act, and most other modern privacy regimes. Even when you only use a number for a transient validation check, regulators expect you to have a lawful basis for the processing, minimize retention, disclose your phone-number handling in your privacy policy, and honor deletion requests within statutory deadlines.
This validator does not log the numbers you submit. We record only anonymous counters (success / failure / detected country) for traffic analytics, plus per-IP rate-limit timestamps that expire within 60 seconds. The number you enter is processed in memory and discarded.
How this tool works
WhoseNo runs on a curated numbering-plan dataset combining the ITU-T E.164 country-code assignments with allocator-published prefix tables Ofcom (UK), the FCC and NANPA (US/Canada), PTA (Pakistan), TRAI (India), CSRA (Saudi Arabia), MCMC (Malaysia), TDRA (UAE), CITRA (Kuwait), and dozens of others alongside operator-prefix data from the same intelligence engine that powers our reverse phone lookup. When you submit a number, the tool strips non-digit characters, detects the country (from the leading + / 00 or from your dropdown selection), normalizes the national portion, runs length and prefix checks against the country plan, and assembles every display format from the verified digits.
The check is purely structural no calls, SMS pings, or HLR queries are placed against the live phone network, and your number is not stored. The same dataset drives our reverse lookup, area-code pages, and country directories, so when you validate on this tool you are using the plan tables that respond to millions of search queries elsewhere on the site.
Frequently asked questions
What is phone number validation?
Phone number validation is the process of checking whether a phone number string matches the official numbering plan of a country correct total length, an allocated prefix, and a recognized line type (mobile, fixed line, toll-free, VoIP, premium rate, etc.). Validation is structural: it answers whether the number could exist, not whether it is currently assigned to a live subscriber. Confirming a live subscriber requires an HLR lookup or an SMS / call verification, which this tool does not perform.
What is E.164 format?
E.164 is the international telephone numbering recommendation published by the ITU. An E.164 number begins with a plus sign, followed by a 1- to 3-digit country calling code and the national subscriber number, with no spaces or punctuation for example, +14155552671. The maximum total length is 15 digits. E.164 is the canonical form for storage, SMS APIs, CRM systems, and SIP signalling. Every other display format is derived from it.
What is the difference between phone number validation and verification?
Validation is structural and offline it checks the number against the country numbering plan without contacting the operator. Verification is live it proves the user has access to the number right now by sending an SMS code or placing a call. Validation costs nothing and runs in milliseconds; verification costs a few cents per attempt and takes seconds. Always validate first; verify only when you need proof of possession (signup, password reset, payment).
What is the difference between validation and formatting?
Validation answers "is this a structurally valid phone number?". Formatting answers "how should I display it?". A number can be formatted into many human-readable styles (E.164, international, national, RFC3966) regardless of whether it is structurally valid. This tool returns both: a yes/no validity flag plus every common display format.
Why does the tool say a number is "possible" but not "valid"?
Possible means the total digit count fits the country plan; valid means the leading digits are also in an allocated range. A number can have the right length but a prefix that is not assigned to any operator usually a typo, sometimes a reserved range like 555-01XX in NANP or 070 in the UK personal-numbering range. Treat possible-but-not-valid numbers the same as invalid for production purposes.
Is this phone number validator free?
Yes. The WhoseNo Phone Number Validator is free to use, requires no signup, and has no usage limits for normal interactive use. The JSON API is rate-limited to 60 requests per minute per IP to prevent abuse; the public web tool is unrestricted.
Do you store the phone numbers I submit?
No. We do not log the actual phone numbers submitted through this tool. We record only anonymous counters (success / failure / detected country) for traffic analytics, plus per-IP rate-limit timestamps that expire within 60 seconds. The number you enter is processed in memory and discarded.
Can I validate a phone number without a country code?
Yes. If you do not include a + or 00 country prefix, the tool uses the country selector dropdown as the default region. If you do include + or 00 followed by the dialing code, the dropdown is ignored and the country is detected from the number itself. For shared dialing codes (the +1 NANP region covers the US, Canada, and 20+ Caribbean countries), the dropdown selection breaks the tie.
What does RFC3966 (the tel: URI) format do?
RFC3966 is the standardized URI scheme for click-to-call for example, tel:+14155552671. Placed in an HTML <a href> or a QR code, it opens the device dialer with the number pre-filled. Always use the E.164 form inside the URI; spaces and punctuation are not permitted.
Does the validator detect mobile vs landline?
Yes, where the country numbering plan publishes that distinction. The tool returns a line type MOBILE, FIXED_LINE, VOIP, TOLL_FREE, PREMIUM_RATE, SHARED_COST, PERSONAL_NUMBER, PAGER, UAN, VOICEMAIL, or UNKNOWN. In countries with full mobile-number portability (most modern markets), the original line-type allocation stays accurate, but the live operator on a given number may have changed since assignment.
Can I use a regex to validate phone numbers?
Only as a sanity check. A pattern like ^\+?[1-9]\d{1,14}$ matches anything that vaguely looks like an E.164 number, but it accepts impossible country codes, ignores per-country length rules, says nothing about line type, and rejects valid short numbers. Use regex as a client-side gate, then validate with a numbering-plan library or this tool before persisting or sending SMS.
How accurate is the line-type detection?
Line-type accuracy depends on the country. Where the regulator publishes per-prefix line-type allocations (US, UK, India, Pakistan, Australia, most EU countries), accuracy is high for the original allocation. After mobile-number portability, the allocation still tells you the original line type but cannot tell you the current operator for that you need an HLR / carrier lookup. Countries that mix landline and mobile across the same prefix range (some Caribbean and African plans) return FIXED_LINE_OR_MOBILE for ambiguous ranges.
Can I validate phone numbers in bulk?
The web form validates one number at a time. The JSON API supports programmatic validation; you can call it from a script in a loop, respecting the 60-requests-per-minute-per-IP limit. A dedicated bulk CSV upload tool is on our roadmap. For very large lists, run libphonenumber locally it is the same numbering-plan dataset.
Does the tool support vanity numbers like 1-800-FLOWERS?
Yes. Letters in the input are converted to digits using the standard ITU keypad mapping (A,B,C → 2; D,E,F → 3; and so on) before validation. 1-800-FLOWERS becomes 1-800-3569377, which is a valid US toll-free number.
How does the tool handle phone-number extensions?
Extensions (ext, x, #, ;ext=) are not part of the dialable number. Strip the extension and store it separately if your application needs it; the validator works on the dialable portion. The "tel:" URI standard supports extensions via the ;ext= parameter for example, tel:+14155552671;ext=142.
What countries does the validator support?
The tool covers every country in the ITU E.164 country-code list (240+ territories). Coverage depth line-type detection, area-code resolution, carrier hints is highest for the 30 most-validated countries: US, Canada, UK, India, Pakistan, Australia, Germany, France, Italy, Spain, Brazil, Mexico, Japan, China, Korea, Singapore, Malaysia, Indonesia, Philippines, Vietnam, Thailand, Saudi Arabia, UAE, Kuwait, Oman, Bahrain, Qatar, South Africa, Nigeria, Turkey, and Poland. Other countries fall back to length-and-country-code validation only.
How does the validator work under the hood?
WhoseNo runs on a curated numbering-plan dataset combining the ITU-T E.164 country-code assignments, allocator-published prefix tables (Ofcom, FCC/NANPA, PTA, TRAI, MCMC and others), and operator-prefix data from the same intelligence engine that powers our reverse phone lookup. Validation is purely structural no calls, SMS pings, or HLR queries are placed against the live phone network.
Can I integrate the validator into my own application?
Yes. The JSON API at /tools/phone-number-validator/api.php accepts POST requests with number and default_region parameters and returns a structured JSON response with validity, country, line type, carrier hints, timezones, and every common display format. The endpoint is same-origin only; if you need third-party access, contact us through the form on /about-us.