You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

libphonenumber-js

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript

1.12.7
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

94

Maintenance

100

License

Version published
Weekly downloads
6.2M
-18.09%
Maintainers
1
Weekly downloads
 
Created

What is libphonenumber-js?

The libphonenumber-js npm package is a JavaScript library that provides a variety of functions for handling and manipulating phone numbers. It is based on Google's libphonenumber library and allows users to parse, format, and validate phone numbers in international formats.

What are libphonenumber-js's main functionalities?

Parsing and formatting phone numbers

This feature allows users to parse a string into a phone number object and format it into an international format.

import { parsePhoneNumberFromString } from 'libphonenumber-js';
const phoneNumber = parsePhoneNumberFromString('+12133734253');
console.log(phoneNumber.formatInternational()); // '+1 213 373 4253'

Validating phone numbers

This feature enables users to check if a given phone number is valid according to international standards.

import { isValidPhoneNumber } from 'libphonenumber-js';
const valid = isValidPhoneNumber('+12133734253');
console.log(valid); // true

Getting phone number information

This feature provides information about the phone number, such as the country it is associated with and the type of number (e.g., mobile, fixed-line).

import { parsePhoneNumberFromString } from 'libphonenumber-js';
const phoneNumber = parsePhoneNumberFromString('+12133734253');
console.log(phoneNumber.country); // 'US'
console.log(phoneNumber.getType()); // 'MOBILE'

Other packages similar to libphonenumber-js

FAQs

Package last updated on 17 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts