libphonenumber is a library for parsing, formatting, and validating international phone numbers across Java, C++, and JavaScript.
The library solves the problem of reliably handling phone numbers across different countries and regions, where formatting conventions, length rules, and valid prefixes vary widely. It provides parsing that extracts components from raw input, formatting that converts numbers to standard representations, and validation that checks whether a number is genuinely possible or fully valid for a given region. Beyond basic validation, it can identify number types such as fixed-line, mobile, toll-free, or VoIP numbers; match two numbers with a confidence level; provide example numbers for any country; and extract geographical, carrier, and timezone information from a phone number.
Developers should adopt this tool if they need robust international phone number handling in a production application. The Java version is particularly suited for Android development, having been integrated into the Android framework since version 4.0. The library's strength lies in its comprehensive metadata covering all countries and regions, its ability to distinguish between number types, and its on-the-fly formatting capability through the AsYouTypeFormatter. It also includes a fast preliminary check via isPossibleNumber that uses only length information, useful when you need quick filtering before full validation. The tool is appropriate for any application that accepts phone numbers from users worldwide and must validate or format them correctly.
The project maintains active development with regular updates to phone number metadata and bug fixes. Contributions are welcomed through pull requests with clear guidelines provided. The team provides supplementary resources including a frequently asked questions document and a document on common misconceptions about phone numbers. Documentation for making metadata changes and running demonstrations is available for contributors and those porting the library to other platforms.