1.2.6 โข Published 5 months ago
phone-number-generator-js v1.2.6
Phone number generator ยท
What is phone number generator?
phone-number-generator-js a versatile JavaScript library that generates random mobile phone numbers in the E.164 format.
With this library, you can easily generate a completely random phone number or configure it to generate numbers specific to a particular country.
It supports a wide range of countries, with a total of 227 supported countries, allowing you to generate phone numbers that are valid and appropriate for various regions across the globe.
By default, if no configuration is provided, a totally random phone number will be generated from any of the 226 supported countries.
Relevant links:
Install
npm install phone-number-generator-js
// or
yarn add phone-number-generator-js
Usage
const { generatePhoneNumber } = require("phone-number-generator-js");
// or
import { generatePhoneNumber } from "phone-number-generator-js";
1. Simple usage
generatePhoneNumber(); // '+85265698900'
2. With config
Using countryName enum
generatePhoneNumber({ countryName: CountryNames.Austria }); // '+436508162890'
Using withCountryCode flag (defaults to true)
generatePhoneNumber({ countryName: CountryNames.Austria, withCountryCode: false }); // '5483746575'
Test
npm run test
// or
yarn test
Build
npm run build
// or
yarn build
Supported countries:
Countries | |||
---|---|---|---|
Afghanistan ๐ฆ๐ซ | Albania ๐ฆ๐ฑ | Algeria ๐ฉ๐ฟ | American Samoa ๐ฆ๐ธ |
Andorra ๐ฆ๐ฉ | Angola ๐ฆ๐ด | Anguilla ๐ฆ๐ฎ | Antigua and Barbuda ๐ฆ๐ฌ |
Argentina ๐ฆ๐ท | Armenia ๐ฆ๐ฒ | Aruba ๐ฆ๐ผ | Australia ๐ฆ๐บ |
Austria ๐ฆ๐น | Azerbaijan ๐ฆ๐ฟ | Bahamas ๐ง๐ธ | Bahrain ๐ง๐ญ |
Bangladesh ๐ง๐ฉ | Barbados ๐ง๐ง | Belarus ๐ง๐พ | Belgium ๐ง๐ช |
Belize ๐ง๐ฟ | Benin ๐ง๐ฏ | Bermuda ๐ง๐ฒ | Bhutan ๐ง๐น |
Bolivia ๐ง๐ด | Bosnia and Herzegovina ๐ง๐ฆ | Botswana ๐ง๐ผ | Brazil ๐ง๐ท |
British Virgin Islands ๐ป๐ฌ | Brunei Darussalam ๐ง๐ณ | Bulgaria ๐ง๐ฌ | Burkina Faso ๐ง๐ซ |
Burundi ๐ง๐ฎ | Cambodia ๐ฐ๐ญ | Cameroon ๐จ๐ฒ | Canada ๐จ๐ฆ |
Cape Verde ๐จ๐ป | Cayman Islands ๐ฐ๐พ | Central African Republic ๐จ๐ซ | Chad ๐น๐ฉ |
Chile ๐จ๐ฑ | China ๐จ๐ณ | Colombia ๐จ๐ด | Comoros ๐ฐ๐ฒ |
Congo ๐จ๐ฉ | Cook Islands ๐จ๐ฐ | Costa Rica ๐จ๐ท | Cรดte D'Ivoire ๐จ๐ฎ |
Croatia ๐ญ๐ท | Cuba ๐จ๐บ | Curaรงao ๐จ๐ผ | Cyprus ๐จ๐พ |
Czech Republic ๐จ๐ฟ | Democratic Republic of the Congo ๐จ๐ฉ | Denmark ๐ฉ๐ฐ | Djibouti ๐ฉ๐ฏ |
Dominica ๐ฉ๐ฒ | Dominican Republic ๐ฉ๐ด | East Timor ๐น๐ฑ | Ecuador ๐ช๐จ |
Egypt ๐ช๐ฌ | El Salvador ๐ธ๐ป | Equatorial Guinea ๐ฌ๐ถ | Eritrea ๐ช๐ท |
Estonia ๐ช๐ช | Eswatini ๐ธ๐ฟ | Ethiopia ๐ช๐น | Falkland Islands (Malvinas) ๐ซ๐ฐ |
Faroe Islands ๐ซ๐ด | Fiji ๐ซ๐ฏ | Finland ๐ซ๐ฎ | France ๐ซ๐ท |
French Guiana ๐ฌ๐ซ | French Polynesia ๐ต๐ซ | Gabon ๐ฌ๐ฆ | Gambia ๐ฌ๐ฒ |
Georgia ๐ฌ๐ช | Germany ๐ฉ๐ช | Ghana ๐ฌ๐ญ | Gibraltar ๐ฌ๐ฎ |
Greece ๐ฌ๐ท | Greenland ๐ฌ๐ฑ | Grenada ๐ฌ๐ฉ | Guadeloupe ๐ฌ๐ต |
Guam ๐ฌ๐บ | Guatemala ๐ฌ๐น | Guinea ๐ฌ๐ณ | Guinea-Bissau ๐ฌ๐ผ |
Guyana ๐ฌ๐พ | Haiti ๐ญ๐น | Honduras ๐ญ๐ณ | Hong Kong ๐ญ๐ฐ |
Hungary ๐ญ๐บ | Iceland ๐ฎ๐ธ | India ๐ฎ๐ณ | Indonesia ๐ฎ๐ฉ |
Iran ๐ฎ๐ท | Iraq ๐ฎ๐ถ | Ireland ๐ฎ๐ช | Israel ๐ฎ๐ฑ |
Italy ๐ฎ๐น | Jamaica ๐ฏ๐ฒ | Japan ๐ฏ๐ต | Jordan ๐ฏ๐ด |
Kazakhstan ๐ฐ๐ฟ | Kenya ๐ฐ๐ช | Kiribati ๐ฐ๐ฎ | Korea, Republic of ๐ฐ๐ท |
Kuwait ๐ฐ๐ผ | Kyrgyzstan ๐ฐ๐ฌ | Lao People's Democratic Republic ๐ฑ๐ฆ | Latvia ๐ฑ๐ป |
Lebanon ๐ฑ๐ง | Lesotho ๐ฑ๐ธ | Liberia ๐ฑ๐ท | Libya ๐ฑ๐พ |
Liechtenstein ๐ฑ๐ฎ | Lithuania ๐ฑ๐น | Luxembourg ๐ฑ๐บ | Macao ๐ฒ๐ด |
Macedonia, the Former Yugoslav Republic Of ๐ฒ๐ฐ | Madagascar ๐ฒ๐ฌ | Malawi ๐ฒ๐ผ | Malaysia ๐ฒ๐พ |
Maldives ๐ฒ๐ป | Mali ๐ฒ๐ฑ | Malta ๐ฒ๐น | Marshall Islands ๐ฒ๐ญ |
Martinique ๐ฒ๐ถ | Mauritania ๐ฒ๐ท | Mauritius ๐ฒ๐บ | Mexico ๐ฒ๐ฝ |
Micronesia, Federated States Of ๐ซ๐ฒ | Moldova, Republic of ๐ฒ๐ฉ | Monaco ๐ฒ๐จ | |
Mongolia ๐ฒ๐ณ | Montenegro ๐ฒ๐ช | Montserrat ๐ฒ๐ธ | Morocco ๐ฒ๐ฆ |
Mozambique ๐ฒ๐ฟ | Myanmar ๐ฒ๐ฒ | Namibia ๐ณ๐ฆ | Nauru ๐ณ๐ท |
Nepal ๐ณ๐ต | Netherlands ๐ณ๐ฑ | New Caledonia ๐ณ๐จ | New Zealand ๐ณ๐ฟ |
Nicaragua ๐ณ๐ฎ | Niger ๐ณ๐ช | Nigeria ๐ณ๐ฌ | Niue ๐ณ๐บ |
Norfolk Island ๐ณ๐ซ | Northern Mariana Islands ๐ฒ๐ต | Norway ๐ณ๐ด | Oman ๐ด๐ฒ |
Pakistan ๐ต๐ฐ | Palau ๐ต๐ผ | Panama ๐ต๐ฆ | Papua New Guinea ๐ต๐ฌ |
Paraguay ๐ต๐พ | Peru ๐ต๐ช | Philippines ๐ต๐ญ | Pitcairn ๐ต๐ณ |
Poland ๐ต๐ฑ | Portugal ๐ต๐น | Puerto Rico ๐ต๐ท | Qatar ๐ถ๐ฆ |
Rรฉunion ๐ท๐ช | Romania ๐ท๐ด | Russian Federation ๐ท๐บ | Rwanda ๐ท๐ผ |
Saint Helena ๐ธ๐ญ | Saint Kitts And Nevis ๐ฐ๐ณ | Saint Lucia ๐ฑ๐จ | Saint Pierre And Miquelon ๐ต๐ฒ |
Saint Vincent And The Grenedines ๐ป๐จ | Samoa ๐ผ๐ธ | San Marino ๐ธ๐ฒ | Sao Tome and Principe ๐ธ๐น |
Saudi Arabia ๐ธ๐ฆ | Senegal ๐ธ๐ณ | Serbia ๐ท๐ธ | Seychelles ๐ธ๐จ |
Sierra Leone ๐ธ๐ฑ | Singapore ๐ธ๐ฌ | Sint Maarten ๐ธ๐ฝ | Slovakia ๐ธ๐ฐ |
Slovenia ๐ธ๐ฎ | Solomon Islands ๐ธ๐ง | Somalia ๐ธ๐ด | South Africa ๐ฟ๐ฆ |
South Sudan ๐ธ๐ธ | Spain ๐ช๐ธ | Sri Lanka ๐ฑ๐ฐ | Sudan ๐ธ๐ฉ |
Suriname ๐ธ๐ท | Sweden ๐ธ๐ช | Switzerland ๐จ๐ญ | Syrian Arab Republic ๐ธ๐พ |
Taiwan ๐น๐ผ | Tajikistan ๐น๐ฏ | Tanzania, United Republic of ๐น๐ฟ | Thailand ๐น๐ญ |
Timor-Leste ๐น๐ฑ | Togo ๐น๐ฌ | Tokelau ๐น๐ฐ | Tonga ๐น๐ด |
Trinidad and Tobago ๐น๐น | Tunisia ๐น๐ณ | Turkey ๐น๐ท | Turkmenistan ๐น๐ฒ |
Turks and Caicos Islands ๐น๐จ | Tuvalu ๐น๐ป | Uganda ๐บ๐ฌ | Ukraine ๐บ๐ฆ |
United Arab Emirates ๐ฆ๐ช | United Kingdom ๐ฌ๐ง | United States ๐บ๐ธ | Uruguay ๐บ๐พ |
Uzbekistan ๐บ๐ฟ | Vanuatu ๐ป๐บ | Venezuela, Bolivarian Republic of ๐ป๐ช | Vietnam ๐ป๐ณ |
Virgin Islands, British ๐ป๐ฌ | Virgin Islands, U.S. ๐ป๐ฎ | Wallis and Futuna ๐ผ๐ซ | Yemen ๐พ๐ช |
Zambia ๐ฟ๐ฒ | Zimbabwe ๐ฟ๐ผ |
Credits
- Validating that the generated phone number is valid & following the E.164 format - libphonenumber-js
- Countries phone number data (country code, mobile starting digits & length) - phone