libphonenumber for Salesforce
Google libphonenumber is the reference library for parsing, validating, and formatting phone
numbers, with official versions for Java, C++, and JavaScript. Apex cannot load any of them.
NumberForge ports the Java library to Apex and ships it as a managed package with a global
NF API, currently on libphonenumber v9.0.42.
What is ported
| libphonenumber (Java) | Purpose |
|---|---|
PhoneNumberUtil | Parse, validate, format, number types, possible lengths, regions |
AsYouTypeFormatter | Format digits as they are typed |
PhoneNumberMatcher | Find phone numbers in free text |
ShortNumberInfo | Emergency and short codes |
PhoneNumberOfflineGeocoder | Geographic description of a number |
PhoneNumberToCarrierMapper | Original carrier name |
PhoneNumberToTimeZonesMapper | Time zones for a number |
Phone metadata, short-number data, carrier names, geocoding, and time zones are generated from the libphonenumber resource files of a pinned release and packaged as static resources. Nothing is fetched at runtime, so there are no callouts and no data leaves the org.
Checked against the Java library
Every upstream bump runs the same inputs through the official Java library and through the Apex port, and compares the results. For v9.0.42 that is 21,207 cases across 19 API areas, from parsing and formatting to as-you-type, number matching, short numbers, geocoding, carriers, and time zones. A release ships only when every case matches.
Apex example
String region = NF.orgDefaultRegion != null ? NF.orgDefaultRegion : 'US';
try {
NF.Phone phone = NF.parse(contact.Phone, region);
if (NF.isValid(phone)) {
contact.Phone = NF.format(phone, NF.Format.E164);
}
} catch (NF.ParseException e) {
contact.Phone.addError('Enter a valid phone number.');
}
for (NF.Match hit : NF.findNumbers(someCase.Description, 'US')) {
System.debug(hit.rawString() + ' → ' + NF.format(hit.number(), NF.Format.E164));
} Method names stay close to libphonenumber, so code written against the Java API translates with little change. Each page of the API reference names the libphonenumber class and method it corresponds to.
More than a library
The same package includes save-time field rules configured without code, Flow actions, and a Phone Assistant component for record pages, so admins and developers work from one engine.
Questions
Is this the official Google libphonenumber?
No. NumberForge is an independent Apex port of the Java library, distributed as a commercial Salesforce managed package. It is not affiliated with or endorsed by Google; the Apache License 2.0 attribution is in the package and on the third-party notices page.
Which libphonenumber version does it use?
v9.0.42. Each upstream release is ported, checked against the Java library, and listed in the release notes with the bundled version.
Can I call it from triggers, batch Apex, and REST endpoints?
Yes. NF is a global class with static methods, so any Apex in your org can call it, alongside the no-code field rules and Flow actions in the same package.
-
NF API Reference
Every method with parameters, examples, and the matching libphonenumber call.
-
Method index
Complete list of NF entry points.
-
Release notes
Bundled libphonenumber version for each NumberForge release.
One plan: €29,99 per org / month or €299 per year. Sandbox orgs are free. Pricing · Third-party notices · Install