Google's shared Java, C++, and JavaScript library parses, formats, and validates phone numbers worldwide, with helpers for typing, matching, geocoding, and carrier or timezone lookup.
Overview
libphonenumber is a multi-language library for working with international telephone numbers. It normalizes user input into structured phone number objects, checks validity and possibility by region, and formats numbers for display or outbound dialing patterns.
Core APIs distinguish number types such as fixed-line, mobile, toll-free, and voIP where metadata allows, compare whether two numbers might match, and supply example numbers per country or type. An as-you-type formatter updates the display as digits are entered, and findNumbers locates phone numbers inside free text.
Optional mappers add geography from an offline geocoder, original carrier assignment (not current carrier after portability), and time zones tied to a number. The Java implementation targets smartphone use and is integrated with the Android platform; separate demos cover Java, JavaScript, and an example Android formatter app in the project.
Consumers integrate via Maven or published jars for Java, with additional third-party ports maintained outside the core team. Metadata-driven behavior is versioned on a regular release cadence documented in project notes.
Key features
- Parse and validate global phone numbers
- Format for national and international display
- As-you-type number formatting
- Number type and match confidence checks
- Example numbers per country and type
- Find numbers inside text
- Offline geocoding mapper
- Carrier and timezone metadata mappers
Use cases
- Validating user phone input in apps
- Formatting numbers for SMS or dialer UIs
- Detecting numbers in unstructured text
- Showing region hints from a phone number
- Android apps using platform-style parsing