libphonenumber-js guides
Short, practical guides with working code for developers who handle phone numbers. Each one links to a tool you can try in your browser.
How to install libphonenumber-jsInstall libphonenumber-js with npm, yarn or a CDN. Compare the min, max and mobile builds with measured bundle sizes, and see TypeScript and import examples.Read the guide Using libphonenumber-js in ReactValidate a phone number input in React with libphonenumber-js. Working hook and component, with country selection, error messages and React Native notes.Read the guide Using libphonenumber-js in Vue and AngularValidate phone numbers in Vue 3 and Angular with libphonenumber-js. A composable for Vue and a reusable validator for Angular reactive forms.Read the guide How to get the country code from a phone numberFind the country and calling code of a phone number in JavaScript with libphonenumber-js. Includes the full country list, getCountryCallingCode and a live checker.Read the guide Format a phone number as the user typesUse the AsYouType class in libphonenumber-js to format phone numbers while typing. Includes a live demo, default country handling and cursor tips.Read the guide libphonenumber-js vs Google libphonenumberHow libphonenumber-js differs from Google's libphonenumber and its ports for Java, Python, PHP, C# and Go. What each one includes and which to pick.Read the guide Validate a phone number in JavaScript: regex or library?Should you validate phone numbers with a regex or a library? See where common regex patterns fail, with examples, and when each approach is the right choice.Read the guide
Want to try the library first? Open the libphonenumber-js playground.