google/libphonenumber is one of the open-source repositories TopGit tracks, currently at 18.2k stars, written primarily in C++. Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
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.37.
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 at
https://javadoc.io/doc/com.googlecode.libphonenumber/libphonenumber/.
Versioning and Announcements
We generally choose the release number following these guidelines.
If any of the changes pushed to master since the last release are incompatible
with the intent / specification of an existing libphonenumber API or may cause
libphonenumber (Java, C++, or JS) clients to have to change their code to keep
building, we publish a major release. For example, if the last release were
7.7.3, the new one would be 8.0.0.
If any of those changes enable clients to update their code to take advantage
of new functionality, and if clients would have to roll-back these changes in
the event that the release was marked as "bad", we publish a minor release. For
example, we'd go from 7.7.3 to 7.8.0.
Otherwise, including when a release contains only
metadata changes, we publish a sub-minor release,
e.g. 7.7.3 to 7.7.4.
Sometimes we make internal changes to the code or metadata that, while not
affecting compatibility for clients, could affect compatibility for porters
of the library. For such changes we make announcements to
libphonenumber-discuss. Such changes
are not reflected in the version number, and we would publish a sub-minor
release if there were no other changes.
Want to get notified of new releases? During most of the year, excepting
holidays and extenuating circumstances, we release fortnightly. We update
release tags and
document detailed release notes.
We also send an announcement to libphonenumber-discuss for every
release.
Quick Examples
Let's say you have a string representing a phone number from Switzerland. This
is how you parse/normalize it into a PhoneNumber object:
PhoneNumber is a class that was originally auto-generated from
phonenumber.proto with necessary modifications for efficiency. For details on
the meaning of each field, refer to resources/phonenumber.proto.
You could also choose to format the number in the way it is dialed from another
country:
// Produces "011 41 44 668 1800", the number when it is dialed in the United States.
System.out.println(phoneUtil.formatOutOfCountryCallingNumber(swissNumberProto, "US"));
Caveat: We do not provide data about the current carrier of a phone number, only
the original carrier who is assigned the corresponding range. Read about number
portability.
More examples on how to use the library can be found in the unit
tests.
Third-party Ports
Several third-party ports of the phone number library are known to us. We share
them here in case they're useful for developers.
However, we emphasize that these ports are by developers outside the
libphonenumber project. We do not evaluate their quality or influence their
maintenance processes.
Android-optimized: Our Java version loads the metadata from
Class#getResourcesAsStream and asks that Android apps follow the Android
loading best practices of repackaging the metadata and loading from
AssetManager#open() themselves
(FAQ).
If you don't want to do this, check out the port at
https://github.com/MichaelRocks/libphonenumber-android, which does repackage
the metadata and use AssetManager#open(), and may be depended on without
needing those specific loading optimizations from clients. You should also check
out the port at https://github.com/lionscribe/libphonenumber-android which also
supports geocoding, and only requires a one line code change.
Javascript: If you don't want to use our version, which depends on Closure,
there are several other options, including
https://github.com/catamphetamine/libphonenumber-js - a stripped-down
rewrite, about 110 KB in size - and
https://github.com/seegno/google-libphonenumber - a browserify-compatible
wrapper around the original unmodified library installable via npm, which
packs the Google Closure library, about 420 KB in size.
Tools based on libphonenumber metadata:
Scala: https://github.com/mr-tolmach/raf - library for generating valid phone numbers in the E.164 format
How active is development on google/libphonenumber?
The most recent commit recorded on google/libphonenumber was 7 days ago, based on the GitHub push timestamp. The repository has 2.2k forks — one of the better signals of community interest.
How many stars does google/libphonenumber have?
google/libphonenumber has 18.2k GitHub stars — refresh the page for the live number, or check github.com/google/libphonenumber. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is google/libphonenumber open source?
Yes — google/libphonenumber ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/google/libphonenumber.
What is google/libphonenumber?
google/libphonenumber (google/libphonenumber) is a C++ project on GitHub. From the project's own README: Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.
Where do I read more about google/libphonenumber?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/google/libphonenumber is the definitive source.
Read full README in the tab above.
Curious whether libphonenumber is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about libphonenumber.