The most comprehensive JavaScript library for phone number formatting, validation, and analysis with complete international database support
Experience the power of Phone Forge with our interactive demo. Format any phone number and see automatic country detection in action.
Everything you need for professional phone number handling in modern JavaScript applications
Multiple output formats including US, International, National, and E.164 standards with automatic country detection.
Complete database of 249+ countries with ISO codes, dial codes, and flag emojis. Always up-to-date and comprehensive.
Country-specific validation rules with strict and lenient modes. Validate phone numbers accurately worldwide.
Intelligent country detection from phone numbers. Automatically identify origin country and format accordingly.
Get detailed information about any phone number including possible countries, formats, and validation status.
Optimized for speed and efficiency. Zero external dependencies. Handles thousands of operations per second.
See how easy it is to integrate Phone Forge into your projects
const { formatPhoneNumber, isValidPhoneNumber } = require('phone-forge'); // Basic formatting formatPhoneNumber("2128691246"); // Returns: "+1 (212) 869-1246" // International formatting formatPhoneNumber("447700900123", { format: "international", autoDetect: true }); // Returns: "+44 7700900123" // Validation isValidPhoneNumber("(212) 869-1246"); // Returns: true
const { formatPhoneNumber, getPhoneNumberInfo } = require('phone-forge'); // E.164 format formatPhoneNumber("2128691246", { format: "e164", countryCode: "US" }); // Returns: "+12128691246" // Get detailed information const info = getPhoneNumberInfo("447700900123"); console.log(info.possibleCountries[0].countries[0].name); // Returns: "United Kingdom" // Multiple format options console.log(info.formats); // Returns: { // international: "+44 7700900123", // e164: "+447700900123", // national: "07700 900123" // }
import { formatPhoneNumber, FormatOptions, PhoneNumberInfo } from 'phone-forge'; const options: FormatOptions = { format: "international", countryCode: "DE", autoDetect: true }; const formatted: string = formatPhoneNumber("15123456789", options); // Returns: "+49 15123456789" const info: PhoneNumberInfo = getPhoneNumberInfo("447700900123"); console.log(info.valid); // true console.log(info.possibleCountries.length); // 1
const { phoneUtils } = require('phone-forge'); // Get country by dial code const country = phoneUtils.getCountryByDialCode("+49"); console.log(country.name); // "Germany" // Search countries const results = phoneUtils.searchCountries({ name: "United", dialCode: "+1" }); // Get all dial codes const codes = phoneUtils.getAllDialCodes(); // ["+1", "+7", "+20", "+27", ...] // Database statistics const stats = phoneUtils.getDatabaseStats(); console.log(`${stats.totalCountries} countries supported`);
Get started with Phone Forge in seconds