October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Check Whether a Phone Number Is Real in Python

Python’s phonenumbers library can check whether a number matches known regional numbering patterns. Confirm user control separately with an SMS or voice verification challenge.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python can tell you whether a phone number matches a region’s known numbering-plan patterns, but that does not prove the number is currently assigned, reachable, or owned by the person who entered it. Use Google’s Python port of libphonenumber to check the pattern; if you need to confirm control of the number, send a verification code by SMS or automated call and require the user to complete the challenge.

What “real” means in a phone-number check

There are three different checks that are easy to confuse:

As an Amazon Associate I earn from qualifying purchases.

  • Well-formed: The input can be parsed or formatted as a phone-number-like value. Parsing is not strict input sanitization; a parser may extract a number from surrounding text.
  • Matches a numbering-plan pattern: The number’s length and prefix fit a range documented for a region. This is what libphonenumber’s full validity check assesses.
  • Currently assigned, reachable, or controlled: A local numbering-pattern check cannot establish these facts. To confirm that a user can receive messages or calls at a number, require them to complete a verification challenge sent to it.

As the libphonenumber FAQ cautions, “Do not rely on libphonenumber to determine whether numbers are currently assigned to a specific user and reachable.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check a number in Python

Google libphonenumber has a Python port, phonenumbers. Its project documentation distinguishes a looser possible-number check from a stricter validity check. The following illustrates the intended flow; consult the package’s current official documentation for installation instructions and API details before using it in production.

import phonenumbers
from phonenumbers import NumberParseException

raw = "020 7031 3000"
region = "GB"  # Use a selected/default region for national-format input.

try:
    parsed = phonenumbers.parse(raw, region)
except NumberParseException:
    print("Could not parse this as a phone number")
else:
    if not phonenumbers.is_possible_number(parsed):
        print("Number length is not plausible for the region")
    elif not phonenumbers.is_valid_number(parsed):
        print("Number does not match known numbering-plan patterns")
    else:
        print("Matches known numbering-plan patterns; ownership/reachability unverified")

This example is illustrative, not a report of a tested run. The project’s README describes the library’s validation features and points to the Python implementation; the Python package documentation is the place to check current installation and API details. No particular current package release is established here.

Possible versus valid: what each result tells you

Check Evidence checked What a positive result means What it does not prove
Possible Primarily whether the length is plausible for the region. The number’s length is plausible under the relevant numbering rules. It does not establish that the prefix matches a valid range, or that the number is assigned, reachable, or controlled by the user.
Valid Length and known prefix patterns in the library’s numbering metadata. The number fits a documented range from which carriers may assign numbers. It does not establish current assignment, reachability, SMS capability, or user ownership.

The project’s FAQ defines validity at the range level: carriers may freely assign numbers within a valid range. The versioned PhoneNumberUtil API reference describes the possible-number check as less strict than full validity.

Choose the check that fits your application

To reject obvious input errors

Parse the input with the right regional context, then use the possible-number check as a basic length plausibility test. A parse failure is different from a parsed number that fails this test, so handle those outcomes separately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To accept numbers that match numbering rules

Use the full validity check for regions your application supports. A positive result means the number matches known numbering-plan patterns; it is not evidence that the number is live or belongs to the user.

To confirm a user can receive a message or call

Send a one-time code by SMS or automated call and require the user to enter or otherwise complete the challenge. That verifies control of the channel at the time of the challenge more directly than numbering metadata; a pattern check alone cannot do it.

Use the right region and handle scope carefully

  • National-format input: Provide the selected or otherwise appropriate region when parsing a number without an international country calling code. In the example, GB supplies the region context for a UK-format number.
  • International input: Include the country calling code so the number identifies its numbering plan without relying on a national-format default.
  • Numbers from another region: Do not require a number’s region to match the user’s residence. The project FAQ notes that people may use numbers from a different region, including mobile or VoIP numbers.
  • Short codes: Service and emergency short numbers are outside the regular PhoneNumberUtil path. The project FAQ directs developers to the separate ShortNumberInfo utility.
  • Number type: A classification such as “mobile” is based on numbering patterns. It does not prove present SMS capability, reachability, or ownership.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Limits of pattern validation and dialing tests

Numbering metadata can lag official changes. The project FAQ says its metadata relies on authoritative documentation, but updates may lag notification or reporting. A failed validity check can therefore reflect the metadata as well as the number itself.

Even a successful call is not conclusive evidence that the exact digits entered form a valid number. The FAQ describes cases where extra digits may be ignored or operators may repair older dialing patterns during numbering transitions. For a user-facing application, treat a call or SMS challenge—not local validation or a successful dial—as the check of whether the user can receive a communication at that number.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.