python-phonenumbers: Google's libphonenumber Port for Python

This repository profile is provided by osrepos.com, an open source repository discovery platform.

python-phonenumbers: Google's libphonenumber Port for Python

Summary

`python-phonenumbers` is a robust Python port of Google's highly acclaimed `libphonenumber` library. It offers comprehensive functionality for parsing, validating, and formatting international phone numbers, making it an indispensable tool for global applications. This library ensures accurate and standardized phone number handling across diverse regions.

Repository Information

Analyzed by OSRepos on July 30, 2026

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

python-phonenumbers is the official Python port of Google's libphonenumber library, a powerful and widely used tool for handling international phone numbers. This library provides a comprehensive suite of functionalities, including parsing, validation, formatting, and extracting metadata for phone numbers from various countries. It's designed to work seamlessly across Python 2.5-2.7 and Python 3.x, offering a consistent experience for developers.

Whether you need to verify user input, standardize phone number displays, or extract geographical information, python-phonenumbers offers a reliable and well-maintained solution, mirroring the capabilities of its Java counterpart.

Installation

Getting started with python-phonenumbers is straightforward. You can install it using pip:

pip install phonenumbers

Examples

Let's explore some of the core functionalities of python-phonenumbers with practical examples.

Parsing and Validation

The library allows you to parse phone numbers from strings and then validate them for possibility and validity.

import phonenumbers

# Parse a number with a known region
x = phonenumbers.parse("020 8366 1177", "GB")
print(x)
# Output: Country Code: 44 National Number: 2083661177 Leading Zero: False

# Parse an E.164 number
y = phonenumbers.parse("+442083661177", None)
print(y)
# Output: Country Code: 44 National Number: 2083661177 Leading Zero: False

# Check if numbers are possible or valid
invalid_number = phonenumbers.parse("+120012301", None)
print(f"Is possible: {phonenumbers.is_possible_number(invalid_number)}") # False
print(f"Is valid: {phonenumbers.is_valid_number(invalid_number)}")     # False

valid_but_unassigned = phonenumbers.parse("+12001230101", None)
print(f"Is possible: {phonenumbers.is_possible_number(valid_but_unassigned)}") # True
print(f"Is valid: {phonenumbers.is_valid_number(valid_but_unassigned)}")     # False (NPA 200 not used)

Formatting Phone Numbers

You can format parsed PhoneNumber objects into various standard formats.

import phonenumbers

number = phonenumbers.parse("+442083661177", None)

print(f"National format: {phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.NATIONAL)}")
# Output: National format: 020 8366 1177

print(f"International format: {phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)}")
# Output: International format: +44 20 8366 1177

print(f"E.164 format: {phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.E164)}")
# Output: E.164 format: +442083661177

Geocoding and Carrier Information

The library also provides extended functionality to retrieve geographical and carrier information for phone numbers. Note that these require importing specific sub-packages.

from phonenumbers import geocoder, carrier
import phonenumbers

# Geocoding
ch_number = phonenumbers.parse("0431234567", "CH")
print(f"Location (English): {geocoder.description_for_number(ch_number, 'en')}")
# Output: Location (English): Zurich

# Carrier information
ro_number = phonenumbers.parse("+40721234567", "RO")
print(f"Carrier (English): {carrier.name_for_number(ro_number, 'en')}")
# Output: Carrier (English): Vodafone

Why Use python-phonenumbers?

python-phonenumbers is an indispensable library for any application dealing with phone numbers globally. Its key advantages include:

  • Accuracy and Reliability: Directly ported from Google's libphonenumbers, it inherits a vast and frequently updated dataset of phone number metadata, ensuring high accuracy in parsing and validation.
  • Internationalization: Supports phone numbers from all over the world, handling country codes, national prefixes, and various formatting conventions.
  • Comprehensive Features: Beyond basic parsing and formatting, it offers advanced features like "as-you-type" formatting, finding numbers in text, geocoding, and carrier identification.
  • Active Maintenance: The library is actively maintained, keeping pace with changes in global telephony standards and data.
  • Memory Management: It intelligently loads metadata on-demand, and provides options for managing memory overhead for extended functionalities.

Links

Related repositories

Similar repositories that may be relevant next.

Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

September 27, 2026

Meshtastic-MCP provides an MCP server and agent skills designed for AI tooling to discover, drive, observe, and test Meshtastic devices and applications. It offers a comprehensive suite of capabilities, from portable device control to advanced hardware-free end-to-end testing and replay functionalities. This project aims to streamline the development and testing of Meshtastic ecosystems.

PythonMeshtasticAI
AutoResearch: AI/ML Research Agents from Idea to Paper-Ready Evidence

AutoResearch: AI/ML Research Agents from Idea to Paper-Ready Evidence

September 22, 2026

AutoResearch is an open-source agent workflow designed for AI and machine learning research. It automates the entire research process, from generating ideas and planning experiments to execution, analysis, and independent evaluation. This project helps researchers produce paper-ready evidence efficiently and with traceable provenance.

PythonAIMachine Learning
HarnessRouter: Unified Interface for AI Agent Harnesses

HarnessRouter: Unified Interface for AI Agent Harnesses

September 22, 2026

HarnessRouter Community Edition provides a self-hosted, Apache-2.0 licensed unified interface for various AI agent harnesses like Codex, Claude Code, and Hermes. It allows users to run multiple agents through a single API, offering features such as sessions, streaming, file handling, and cancellation. The project implements the open-standard Unified Harness Protocol (UHP), ensuring users maintain control over their keys and infrastructure.

AI AgentsAgent FrameworkLLM
AREX-Skill: A Skill Library for Automated Machine Learning and Auto-Research

AREX-Skill: A Skill Library for Automated Machine Learning and Auto-Research

September 21, 2026

AREX-Skill is a powerful skill library designed to advance automated machine learning and auto-research. It distills over 5,000 executable skills from more than 1,000 popular GitHub repositories, making complex ML knowledge directly usable by coding agents. This project significantly enhances agent performance in various research tasks by providing structured, validated operating knowledge.

PythonAutomated Machine LearningAI Agents

Source repository

Open the original repository on GitHub.

16 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️