libphonenumber-js
libphonenumber-js is a free JavaScript and TypeScript library for parsing and formatting personal phone numbers.
What libphonenumber-js is
libphonenumber-js is a free JavaScript and TypeScript library for parsing and formatting personal phone numbers. It checks whether a number’s length is possible and whether its digits follow phone-number rules. Its “As You Type” formatter handles complete or partial number input, and a text-search function finds complete numbers, including those with extensions. Developers can choose min, max, mobile, or custom metadata to balance supported checks with bundle size. The listed full build is 145 kB, including 65 kB of code and 80 kB of metadata; the README compares this with 550 kB for Google’s library. Installation is available through npm, a web-page script tag, or an npm CDN such as unpkg or jsDelivr. The library is free under MIT and Apache-2.0 licenses. It does not cover special cases such as emergency numbers, short codes, alphabetic numbers, or geolocation. Its live formatter accepts digits and an initial plus sign, ignores other punctuation, and cannot accept extensions. Strict digit validation may become stale as numbering plans change.
Good
- Checks possible length and digit validity.
- Formats complete and partial number input.
- Finds phone numbers in text, including extensions.
- Offers metadata choices to balance checks and bundle size.
- Free under MIT and Apache-2.0 licenses.
Watch out
- Does not handle emergency numbers, short codes, or geolocation.
- Live formatter does not support entering extensions.
- Strict digit validation can become stale.
- Does not provide carrier data or bulk validation.
Who it suits
It suits developers who need phone-number parsing, formatting, validation, or text search in JavaScript or TypeScript projects. Developers building a React phone-number component are directed to the separate react-phone-number-input project.
Verdict
libphonenumber-js covers common personal phone-number parsing and formatting needs, with validation, text search, and metadata options. Consider its stated limits around special number types and its validation caveat when choosing it.
Plans and prices
From libphonenumber-js's own pricing page, checked 8 Oct 2001.
| Plan | Price | What it gives you |
|---|---|---|
| libphonenumber-js | Free | Open-source JavaScript/TypeScript library · MIT and Apache-2.0 licenses |
The facts
Each one read from libphonenumber-js's own pages, with the date it was checked.
What it does
- Bundle size
- The README compares its 145 kB full build (65 kB code plus 80 kB metadata) with 550 kB for Google’s library.checked 8 Oct 2001
- Input caveat
- The “As You Type” formatter accepts digits and an initial plus sign, ignores other punctuation, and does not support entering extensions.checked 8 Oct 2001
- Live formatting
- Its “As You Type” formatter parses and formats complete or incomplete phone-number input.checked 8 Oct 2001
- Metadata options
- Developers can choose min, max, mobile, or custom metadata to balance supported checks and bundle size.checked 8 Oct 2001
- Notable limits
- It does not handle emergency numbers, short codes, alphabetic numbers, or geolocation, among other special cases described in the README.checked 8 Oct 2001
- Purpose
- A smaller JavaScript/TypeScript rewrite of Google Android’s libphonenumber for parsing and formatting personal phone numbers.checked 8 Oct 2001
- React integration
- The README directs developers building a React phone-number component to the separate react-phone-number-input project.checked 8 Oct 2001
- Repository status
- The README identifies GitLab as the primary repository and says GitHub is used as a backup.checked 8 Oct 2001
- Support
- The README says issues can be reported on GitHub or GitLab and gives instructions for reporting behavior differences from Google’s library.checked 8 Oct 2001
- Text search
- The library can find complete phone numbers in text, including numbers with extensions.checked 8 Oct 2001
- Validation
- It can check whether a number is possible by length and whether it is valid by checking its digits against phone-number rules.checked 8 Oct 2001
- Validation caveat
- The README cautions that strict digit validation can become stale as numbering plans change and recommends considering length-only validation for some applications.checked 8 Oct 2001
- Web distribution
- The package can be installed with npm or included in a web page through a script tag or npm CDN service such as unpkg or jsDelivr.checked 8 Oct 2001
Alternatives to libphonenumber-js
- 1

IPQualityScore Phone Validation API
Free planAndroidiOSWebAPI7.3Free plan - 2

Veriphone
Free planWebAPISelf-hosted7.3From $10.83 a month - 3
Vonage SMS API
AndroidiOSWebAPI7.1 - 4
Accessibility Test Framework for Android
Free planAndroidLinuxmacOSWindows6.8Free plan - 5

numlookupapi.com
Free planWebAPI6.7From $9.99 a month - 6

PhoneValidationAPI
Free planWebAPI6.7From $14.99 a month
