explaingit

google/libphonenumber

📈 Trending18,021C++Audience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Google's library for parsing, validating, and formatting phone numbers from any country. Handles validation, formatting, carrier lookup, and geographic mapping.

Mindmap

mindmap
  root((libphonenumber))
    What it does
      Parse phone numbers
      Validate numbers
      Format numbers
      Identify line type
    Features
      Geographic lookup
      Carrier mapping
      Time zone detection
      As-you-type formatting
    Tech stack
      Java primary
      C++ implementation
      JavaScript binding
    Use cases
      Phone input forms
      Number validation
      International dialing
      Carrier detection

Things people build with this

USE CASE 1

Build a phone number input field that formats digits as the user types.

USE CASE 2

Validate and parse international phone numbers in a web or mobile app.

USE CASE 3

Determine the carrier and time zone for a given phone number.

USE CASE 4

Find and extract phone numbers from unstructured text or documents.

Tech stack

JavaC++JavaScript

Getting it running

Difficulty · easy Time to first run · 5min
Apache License 2.0, use freely for any purpose, including commercial, as long as you include the license notice and state any changes.

In plain English

libphonenumber is Google's open-source library for working with phone numbers from every country in the world. It provides implementations in Java, C++, and JavaScript. The Java version is the primary one and has been part of the Android operating system since version 4.0. The library can parse a string like "044 668 18 00" (given a country context) into a structured object containing the country code and national number. Once parsed, you can validate whether the number is actually valid for the given region, format it in various standard ways (international format, national format, or the E.164 compact format used by telephone networks), check what type of line it is (mobile, landline, toll-free, VoIP, and others), and determine the geographic area associated with the number. A utility called AsYouTypeFormatter can format a number progressively as a user types each digit, which is useful for building phone number input fields. The library also includes tools for finding phone numbers embedded in free text and for mapping numbers to carriers and time zones. It is updated roughly every two weeks with metadata changes to keep up with new number ranges around the world.

Copy-paste prompts

Prompt 1
How do I use libphonenumber to parse and validate a phone number from user input in my app?
Prompt 2
Show me how to format a phone number in E.164 format using libphonenumber.
Prompt 3
How can I detect whether a phone number is a mobile or landline using libphonenumber?
Prompt 4
I need to implement an as-you-type phone number formatter, how do I use AsYouTypeFormatter from libphonenumber?
Prompt 5
How do I look up the carrier and time zone for a phone number with libphonenumber?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.