# Validate offline with Phone Number Validator JS

> The Node.js library for format, type, carrier, place and time zone checks without an API call, and its license.

[Phone Number Validator JS](https://phone-check.app/license/phone-number-validator) is Phone-Check.app's TypeScript library for Node.js. It validates and formats numbers and maps carrier, place and time zones locally, with no network call.

## Install

```bash
npm install @phonecheck/phone-number-validator-js
```

## Validate and format

```ts
import { parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js';

const phoneNumber = parsePhoneNumberFromString('+14155552671');
if (phoneNumber) {
  phoneNumber.isValid(); // true
  phoneNumber.country; // 'US'
  phoneNumber.formatInternational(); // '+1 415 555 2671'
  phoneNumber.getType(); // for example 'MOBILE' or 'FIXED_LINE'
}
```

## Carrier, place and time zones

```ts
import { carrier, geocoder, timezones, parsePhoneNumberFromString } from '@phonecheck/phone-number-validator-js';

const parsed = parsePhoneNumberFromString('+12125551234');
if (parsed) {
  carrier(parsed, 'en'); // carrier name, when the range has one
  geocoder(parsed, 'en'); // place
  timezones(parsed); // for example ['America/New_York']
}
```

## Library or API?

The library answers from the data it ships with. The API adds what only a live service has: the disposable flag, mobile network codes, and for US numbers the operating carrier, wholesale-hosted flag and exchange data. Many teams format and pre-check in the library, then call the API on the numbers that pass.

## License

The library is under the Business Source License 1.1: free for development and testing, open-source projects and education. Production use in commercial applications, SaaS products and revenue-generating projects needs a commercial license. The plans and how to get one are on the [license page](https://phone-check.app/license/phone-number-validator); the source is on [GitHub](https://github.com/phone-check-app/phone-number-validator-js).
