Well I guess I should have posted sooner, because as usually happens once I post I find the answer.

I only stumbled upon this while using JSFiddle. I noticed that they had dependencies you can add, among them was the JavaScript port of libphonenumber (which I'd already tried to use). While it doesn't load correctly in JSFiddle because the connection is refused, the link still works to a minified version.

See here: Minified JavaScript of libphonenumber-js

Once I dropped this in place, and modified my code a bit, suddenly we're off to the races and everything is golden.

<script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script>
<script type="text/javascript">
     $(".phone-format").keyup(function () {
            var val_old = $(this).val();
            var newString = new libphonenumber.AsYouType('US').input(val_old);
            $(this).focus().val('').val(newString);
    });
</script>

I'm really still curious if I just missed something in all the searching I've done over the last couple days, because I don't feel it should have been this difficult or require this much reverse engineering to be able to find this version of the package.

Oh well, hope this helps someone!

Answer from Chockomonkey on Stack Overflow
🌐
GitHub
github.com › catamphetamine › libphonenumber-js
GitHub - catamphetamine/libphonenumber-js: A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript · GitHub
If you don't mind the extra 65 kB of metadata then use max metadata instead of the default (min) one. Google's library always uses "full" metadata so it will yield different isValidNumber() results compared to the "minimal" metadata used by default in this library. See an example illustrating different results when using /min vs /max vs /mobile metadata · import parseMin from 'libphonenumber-js/min' import parseMax from 'libphonenumber-js/max' import parseMobile from 'libphonenumber-js/mobile' // In Singapore (+65), when a mobile number starts with `8`, // it can only have the second digit in the range of `0..8`. // In a number "+6589555555", the second digit is `9` // which makes it an invalid mobile number.
Starred by 3K users
Forked by 211 users
Languages   JavaScript 98.2% | HTML 1.7%
🌐
CodeSandbox
codesandbox.io › examples › package › libphonenumber-js
libphonenumber-js examples - CodeSandbox
Use this online libphonenumber-js playground to view and fork libphonenumber-js example apps and templates on CodeSandbox.
Discussions

Using libphonenumber with JavaScript in HTML - Stack Overflow
I noticed that they had dependencies you can add, among them was the JavaScript port of libphonenumber (which I'd already tried to use). While it doesn't load correctly in JSFiddle because the connection is refused, the link still works to a minified version. See here: Minified JavaScript of libphonenumber-js · Once I dropped this in place, and modified my code a bit, suddenly we're off to the races and everything is golden. More on stackoverflow.com
🌐 stackoverflow.com
Getting true valid number using asYouType in libphonenumber when its invalid
I've found that those numbers can ... of your 11. ... @YannickK actually , the landline and other numbers that begin with a 0 are considered 10, and they are actually valid (01,04,05 landline) or (03 mobile). for example the demo in their website (10 numbers are valid in that case) else my examlpe of 71 123 12 is not valid which is true (asYouType example demo Here) ... libphonenumber-js by default ... More on stackoverflow.com
🌐 stackoverflow.com
How to use libphonenumber-js node package to format dynamically phone numbers
Hi, I want to replicate the ‘‘As you type’’ effect here: https://catamphetamine.gitlab.io/libphonenumber-js/ It is suggested as a basic try that one can run: import { AsYouType } from ‘libphonenumber-js’ new AsYouType (). input (‘+12133734’) // Outputs: ‘+1 213 373 4’ but ... More on forum.wixstudio.com
🌐 forum.wixstudio.com
0
0
April 15, 2022
angular - How to use Google libphonenumber in Typescript? - Stack Overflow
I want to use Google libphonenumber in my angular project using Typescript. I have searched a lot on the internet and found a lot of stuff but could not find anything that could serve my purpose. M... More on stackoverflow.com
🌐 stackoverflow.com
🌐
npm
npmjs.com › package › libphonenumber-js
libphonenumber-js - npm
1 week ago - If you don't mind the extra 65 kB of metadata then use max metadata instead of the default (min) one. Google's library always uses "full" metadata so it will yield different isValidNumber() results compared to the "minimal" metadata used by default in this library. See an example illustrating different results when using /min vs /max vs /mobile metadata · import parseMin from 'libphonenumber-js/min' import parseMax from 'libphonenumber-js/max' import parseMobile from 'libphonenumber-js/mobile' // In Singapore (+65), when a mobile number starts with `8`, // it can only have the second digit in the range of `0..8`. // In a number "+6589555555", the second digit is `9` // which makes it an invalid mobile number.
      » npm install libphonenumber-js
    
Published   Mar 28, 2026
Version   1.12.41
Author   catamphetamine
🌐
Catamphetamine
catamphetamine.github.io › libphonenumber-js
libphonenumber-js
A simpler and smaller rewrite of Google Android's libphonenumber library.
🌐
UNPKG
unpkg.com › browse › @botique › libphonenumber-js@1.0.27 › README.md
botique/libphonenumber-js/README.md
min.js` ```html <script src="/scripts/libphonenumber-js.min.js"></script> <script> alert(new libphonenumber.AsYouType('US').input('213-373-4253')) </script> ``` ## Customizing metadata This library comes prepackaged with three flavours of metadata * `metadata.full.json` — contains everything, including all regular expressions for precise phone number validation and getting phone number type, but weighs `145 KiloBytes`. * `metadata.min.json` — (default) the minimal one, doesn't contain regular expressions for precise phone number validation and getting phone number type, weighs `80 KiloByte
🌐
GitHub
github.com › catamphetamine › libphonenumber-js › issues › 161
As you type for local phone number · Issue #161 · catamphetamine/libphonenumber-js
January 13, 2018 - Hi, Thank you for great library and ongoing support that you provide. I have the following issue. We use the following input style so visitors input only local phone - example "438331999" The probl...
Find elsewhere
🌐
UNPKG
unpkg.com › browse › libphonenumber-js@1.6.0 › README.md
libphonenumber-js/README.md
I myself don't use TypeScript. Send your pull requests. ## CDN One can use any npm CDN service, e.g. [unpkg.com](https://unpkg.com) or [jsdelivr.net](https://jsdelivr.net) ```html <script src="https://unpkg.com/libphonenumber-js/bundle/libphonenumber-js.min.js"></script> <script> alert(new libphonenumber.AsYouType('US').input('213-373-4253')) </script> ``` <!-- ## Standalone For those who aren't using bundlers for some reason there's a way to build a standalone version of the library * `git clone https://github.com/catamphetamine/libphonenumber-js.git` * `npm install` * `npm run build` * See t
🌐
npm
npmjs.com › package › google-libphonenumber
google-libphonenumber - npm
January 19, 2026 - The "As You Type" formatter is a specialized tool that show the formatting progress as it attempts to discover the right format for the given number. It requires registering every keystroke (input digit) on a new instance of the AsYouTypeFormatter as shown below. // Require `AsYouTypeFormatter`. const AsYouTypeFormatter = require('google-libphonenumber').AsYouTypeFormatter; const formatter = new AsYouTypeFormatter('US'); console.log(formatter.inputDigit('2')); // => 2 console.log(formatter.inputDigit('0')); // => 20 console.log(formatter.inputDigit('2')); // => 202 console.log(formatter.inputD
      » npm install google-libphonenumber
    
Published   Jan 19, 2026
Version   3.2.44
Author   Rui Marinho
🌐
GitHub
github.com › ruimarinho › google-libphonenumber
GitHub - ruimarinho/google-libphonenumber: The up-to-date and reliable Google's libphonenumber package for node.js. · GitHub
The "As You Type" formatter is a specialized tool that show the formatting progress as it attempts to discover the right format for the given number. It requires registering every keystroke (input digit) on a new instance of the AsYouTypeFormatter as shown below. // Require `AsYouTypeFormatter`. const AsYouTypeFormatter = require('google-libphonenumber').AsYouTypeFormatter; const formatter = new AsYouTypeFormatter('US'); console.log(formatter.inputDigit('2')); // => 2 console.log(formatter.inputDigit('0')); // => 20 console.log(formatter.inputDigit('2')); // => 202 console.log(formatter.inputD
Starred by 1.5K users
Forked by 155 users
Languages   JavaScript
🌐
GitHub
github.com › google › libphonenumber › blob › master › javascript › README.md
libphonenumber/javascript/README.md at master · google/libphonenumber
If you don't checkout the dependencies next to libphonenumber: Change the path of the <script src=""> in the html pages to point to wherever base.js is located · Update javascript/build.xml with the correct paths · Run the unit tests to make sure everything is working. Open the following pages with your web browser: javascript/i18n/phonenumbers/phonenumberutil_test.html javascript/i18n/phonenumbers/asyoutypeformatter_test.html
Author   google
🌐
GitHub
github.com › google › libphonenumber
GitHub - google/libphonenumber: Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers. · GitHub
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. 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. The JavaScript demo may be run at various tags; this link will take you to master.
Starred by 17.9K users
Forked by 2.2K users
Languages   C++ 53.4% | Java 29.9% | JavaScript 15.8% | CMake 0.4% | C 0.2% | Closure Templates 0.1%
🌐
Medium
medium.com › @shivamethical › validate-mobile-number-with-their-country-codes-84e3cf2f00aa
Validate Mobile number with their country codes | by Shivam Gupta | Medium
October 18, 2018 - isValidMobile() { var phoneNumber = new libphonenumber.parsePhoneNumber(‘999999999’, ‘IN’) phoneNumber.country === ‘RU’ phoneNumber.number === ‘+78005553535’ phoneNumber.isValid() === true ... Full Stack Engineer (Web/App) working on different JS Technologies & frameworks— Angular, Node, Typescript, Ionic, Firebase, AWS, ElK...Love to write cool stuff
🌐
CloudDefense.ai
clouddefense.ai › code › javascript › example › libphonenumber-js
Top 10 Examples of <!-- -->libphonenumber-js<!-- --> code in Javascript | CloudDefense.AI
_onSubmit() { // hack for issue with phonenumber lib - https://github.com/bl00mber/react-phone-input-2/issues/10 let phone = this.phoneNumber.state.formattedNumber; // remove formatting from phone number phone = "+" + phone.replace(/\D+/g, ""); // get dial code from phone number const formatter = new asYouType(); formatter.input(phone); const phoneCode = formatter.country_phone_code; //format balance let balance; const web3 = web3Service.getWeb3(); if (this.props.balanceUnformatted) { balance = web3.fromWei(this.props.balanceUnformatted, 'ether').toNumber(); } // check that phone number is valid const isValidNumber = (phone || "").length >= 9; if (!isValidNumber) { this.setState({ fetching: false, errorMessage: "Phone number is invalid", phoneError: true }); return; };
🌐
UNPKG
unpkg.com › browse › libphonenumber-js@0.4.38 › README.md
libphonenumber-js
min.js` ```html <script src="/scripts/libphonenumber-js.min.js"></script> <script> alert(new libphonenumber.asYouType('US').input('213-373-4253')) </script> ``` ## Customizing metadata This library comes prepackaged with three flavours of metadata * `metadata.full.json` — contains everything, including all regular expressions for precise phone number validation and getting phone number type, but weighs `130 KiloBytes`. * `metadata.min.json` — (default) the minimal one, doesn't contain regular expressions for precise phone number validation and getting phone number type, weighs `70 KiloByte
🌐
Phrase
phrase.com › home › resources › blog › using libphonenumber for international phone numbers
Using libphonenumber for International Phone Numbers | Phrase
January 3, 2025 - That’s it, our setup is complete. All the library’s methods are exposed on the global libphonenumber object. We can now start writing the code in the app.js file and use our good old console to see the results in action.
🌐
Wix Studio
forum.wixstudio.com › ask the community
How to use libphonenumber-js node package to format dynamically phone numbers - Ask the community - Community Support Forum | Wix Studio
April 15, 2022 - Hi, I want to replicate the ‘‘As you type’’ effect here: https://catamphetamine.gitlab.io/libphonenumber-js/ It is suggested as a basic try that one can run: import { AsYouType } from ‘libphonenumber-js’ new AsYouType (). input (‘+12133734’) // Outputs: ‘+1 213 373 4’ but ...
Top answer
1 of 4
18

When dealing with CommonJS libraries, in TypeScript just like this google-libphonenumber, I'd like to suggest 2 ways about it (Tested by me and works well).

Initially, I'd like to suggest to install from NPM just like this: npm install --save google-libphonenumber.

Then, here we go both ways of using it:

1st Method

Just import it directly

import libphonenumber from 'google-libphonenumber';
class Something {
    constructor() {//Just example, you can chose any method
        const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
        console.log( phoneUtil.getSupportedRegions() );//It should works and give you some output
    }
}

2nd Method

You still can make the power of Typescript typing or just use the existing one by: npm install --save-dev @types/google-libphonenumber.

Since you said that you using Angular, so you can declare that typing just installed at src/tsconfig.app.json ( I am using Angular Version 7 ). Here is an example I have made:

{
  ...
  "compilerOptions": {
    ...
    "types": [
      "google-libphonenumber"
    ]
  },
  ...
}

Then you can just import it like usual, in Typescript "typings" way like follow:

import { PhoneNumberUtil } from 'google-libphonenumber';

class Something {
    constructor() {//Just example, you can chose any method
        const phoneUtil: PhoneNumberUtil = PhoneNumberUtil.getInstance();
        console.log( phoneUtil.getSupportedRegions() );//It should works and give you some output
    }
}
2 of 4
3

you may either go with libphonenumber or google-libphonenumber as both of this library having a good number of installs also google-libphonenumber seems to be more powerful

🌐
Npm
npm.io › package › libphonenumber-getexample
Libphonenumber-getexample NPM | npm.io
This includes validation, parsing, formatting and "as you type" formatting. For example, for an Australian number 438 331 999 Google's demo outputs four sections — "Parsing Result", "Validation Results", "Formatting Results" and "AsYouTypeFormatter Results". In a bug report, first describe ...