explaingit

daviddrysdale/python-phonenumbers

Analysis updated 2026-07-03

3,737PythonAudience · developerComplexity · 2/5Setup · easy

TLDR

A Python library for parsing, validating, and formatting phone numbers from any country, based on Google's libphonenumber. Supports E.164 format, carrier lookup, geographic region detection, and text scanning.

Mindmap

mindmap
  root((python-phonenumbers))
    What it does
      Parse phone numbers
      Validate by country
      Format conversions
    Features
      Text scanning
      Carrier lookup
      Time zone detection
    Formats
      E.164 standard
      National format
      International format
    Setup
      pip install
      Optional data packs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Validate and reformat phone numbers collected from a web form, handling numbers from any country in a consistent E.164 format for database storage.

USE CASE 2

Scan a block of text or customer notes to automatically extract all phone numbers mentioned, regardless of format or country.

USE CASE 3

Look up the geographic region, carrier, and time zone for a phone number to enrich user profile data.

What is it built with?

Pythonpip

How does it compare?

daviddrysdale/python-phonenumbersdjango-haystack/django-haystacklightly-ai/lightly
Stars3,7373,7383,738
LanguagePythonPythonPython
Setup difficultyeasymoderatehard
Complexity2/53/54/5
Audiencedeveloperdeveloperresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Geographic, carrier, and timezone data are in separate optional packages, install only the ones your project needs to keep the footprint small.

In plain English

This is a Python library for working with phone numbers from anywhere in the world. It is a port, meaning a faithful translation into Python, of Google's libphonenumber, which is the same system Google uses internally. The library knows the rules for phone number formats in every country: how many digits they have, what prefixes they use, which number ranges are actually assigned to real carriers, and how numbers should be displayed. The core workflow is: take a phone number as a string, tell the library what country it belongs to (or let it figure that out from an international prefix), and get back a structured object you can work with. From there you can check whether the number is plausible, whether it is actually valid in the real world, and format it in different ways. Common formats include the local national format used within a country, the international format with the country code prefix, and the E.164 format which is a standardized compact form used in databases and APIs. Beyond parsing and formatting, the library supports several related tasks. It can scan a block of text and find all phone numbers hidden inside a sentence or paragraph. It can report the geographic region associated with a number, like a city or country, in multiple languages. For mobile numbers in countries where this data is available, it can identify the carrier that originally issued the number. It can also return the time zone or time zones that correspond to a given number. Memory is handled thoughtfully: the base metadata loads only the country data it actually needs when your code first uses a particular region, rather than loading everything at once. Geographic, carrier, and timezone data are in separate optional packages so you include only what your project actually uses. Installation is a single pip command.

Copy-paste prompts

Prompt 1
I'm building a Python web app that collects phone numbers from users worldwide. Show me how to use python-phonenumbers to validate a number, check if it's real, and reformat it to E.164 for storage.
Prompt 2
Write a Python script using python-phonenumbers to scan a string of text and extract all phone numbers found in it, then print each one in international format.
Prompt 3
Using python-phonenumbers, show me how to look up the country, carrier, and time zone for a given phone number with a code example.

Frequently asked questions

What is python-phonenumbers?

A Python library for parsing, validating, and formatting phone numbers from any country, based on Google's libphonenumber. Supports E.164 format, carrier lookup, geographic region detection, and text scanning.

What language is python-phonenumbers written in?

Mainly Python. The stack also includes Python, pip.

How hard is python-phonenumbers to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is python-phonenumbers for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub daviddrysdale on gitmyhub

Verify against the repo before relying on details.