google /libphonenumber

Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.

★ 18,354⑂ 2,193👁 408⑃ 2,625● 0▤ 241
C++Apache-2.0Created 2014-12-03
下载:v9.0.43libphonenumber-9.0.43 ↓9.0.432026-11-06
+1
日增长
18,354
stars
2,193
forks
408
watchers
2,625
prs
0
issues
241
releases

README

What is it?

Google's common Java, C++ and JavaScript library for parsing, formatting, and
validating international phone numbers. The Java version is optimized for
running on smartphones, and is used by the Android framework since 4.0 (Ice
Cream Sandwich).

 Quick links

   Reporting an issue? Want to send a pull request? See the contribution
    guidelines
   Check the frequently asked questions
   Fun! Falsehoods Programmers Believe About Phone Numbers
   Look for
    READMEs in
    directories relevant to the code you're interested in.
   For contributors and porters: How to run the Java demo
   For porters: How to make metadata changes

 Highlights of functionality

   Parsing, formatting, and validating phone numbers for all countries/regions
    of the world.
   getNumberType - gets the type of the number based on the number itself;
    able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared
    Cost, VoIP, Personal Numbers, UAN, Pager, and Voicemail (whenever feasible).
   isNumberMatch - gets a confidence level on whether two numbers could be
    the same.
   getExampleNumber and getExampleNumberForType - provide valid example
    numbers for all countries/regions, with the option of specifying which type
    of example phone number is needed.
   isPossibleNumber - quickly guesses whether a number is a possible
    phone number by using only the length information, much faster than a full
    validation.
   isValidNumber - full validation of a phone number for a region using
    length and prefix information.
   AsYouTypeFormatter - formats phone numbers on-the-fly when users enter
    each digit.
   findNumbers - finds numbers in text.
   PhoneNumberOfflineGeocoder - provides geographical information related to
    a phone number.
   PhoneNumberToCarrierMapper - provides carrier information related to a
    phone number.
   PhoneNumberToTimeZonesMapper - provides timezone information related to a
    phone number.

 Demo

 Java

The Java demo is updated with a slight
delay after the GitHub release.

Last demo update: v9.0.43.

Note: Even though the library (main branch/maven release)
is at v8.12.57, because of some deployment issues, we were unable to update the
Java demo with the new binary version. We will soon fix this. Meantime, please
use JS demo.

If this number is lower than the latest release's version
number, we are between
releases and the demo may be at either version.

 Demo App

There is a demo Android App called E.164 Formatter in this
repository. The purpose of this App is to show an example of how the library can
be used in a real-life situation, in this case specifically in an Android App
using Java.

 JavaScript

The JavaScript
demo
may be run at various tags; this link will take you to master.

 Java code

To include the Java code in your application, either integrate with Maven (see
wiki) or download the latest
jars from the Maven
repository.

 Javadoc

Javadoc is automatically updated to reflect the 

Latest release

v9.0.43 v9.0.43 2026-11-06
Hi all,

Please find the new JARs on the maven site here.

The new release contains mostly metadata changes.
Thanks to all those who contributed by providing issue reports!
See detailed release notes.

Want to be notified of future releases? Join the discussion group!

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON