Understand E.164, country codes, area codes, and the rules behind valid phone numbers.
E.164 is the international standard for phone numbers. It defines a maximum length of 15 digits and a format that includes a country code and a national subscriber number. E.164 is widely used for VoIP, telecom systems, and international communication standards.
If you store numbers in a database, E.164 is the safest canonical format because it is globally unique and unambiguous. It removes formatting differences like spaces, dashes, and parentheses. As a result, E.164 is the format most telecom APIs and authentication providers expect.
+CountryCode NationalNumber
Example: +1 415 555 2671
E.123 describes how phone numbers are displayed to humans. It focuses on spacing, grouping, and readability, while E.164 focuses on a strict canonical representation for systems. A number can be valid in both formats, but the display rules differ by country.
In practice, you should accept a variety of user input styles, normalize to E.164 for storage, and then format back to an E.123 style for display. This approach keeps both machines and humans happy.
Country codes identify the country or region. Area codes (or national destination codes) identify a specific geographic area or service type within a country.
Country codes are 1 to 3 digits. The numbering plan is managed by the ITU, and no country code is a prefix of another within its zone. That helps international switching systems route calls without ambiguity.
Each country defines its own national numbering plan. This plan determines how many digits are used, which prefixes are reserved for mobile, landline, toll-free, or premium services, and how numbers are grouped for readability.
Some countries use closed numbering plans where all national numbers have the same length. Others use open numbering plans where lengths vary by region or service. When generating test numbers, you should respect these rules to avoid creating unrealistic data.
Many countries use a trunk prefix (often 0) for domestic dialing. The trunk prefix is not part of the E.164 number. When users enter numbers, they may include this prefix, so your validation logic should normalize it out before comparing to E.164 patterns.
International dialing prefixes vary by country (for example 00 in many regions or 011 in the US and Canada). These prefixes are also not part of E.164 and should be stripped during normalization.
Many countries use different prefixes for mobile and landline numbers. For example, the UK uses mobile ranges that start with 7, while landlines have geographic prefixes. Understanding these patterns is essential for realistic test data.
Our generator includes both mobile and landline formats where applicable, and you can reference the country-specific pages for detailed prefixes and examples.
Extensions are common in enterprise environments. They are not part of E.164, but users often type them alongside a main number (for example, "x123" or "ext 123"). When parsing user input, extract extensions into a separate field.
Some systems use subaddressing or SIP parameters, which should also be handled separately. Keep the core phone number clean and store auxiliary routing information in dedicated fields.
Validation should be a multi-step process. First, parse and normalize. Second, detect a country based on prefix and length. Third, validate the national number against known ranges. Finally, format for display and return structured metadata like number type and region.
Formatting rules vary by country. Some regions group numbers in pairs, while others use 3-3-4 or 2-4-4 patterns. Consistent formatting improves readability, especially in user interfaces and contact lists.
A robust parser handles multiple user input styles. Start by removing whitespace and punctuation, then detect a leading plus sign or international access code. Once you have a candidate country code, validate the remaining digits against that country's numbering plan and map it to a national significant number.
Normalization is essential for data quality. Store a single canonical value (E.164) and compute any display formatting dynamically. This prevents data drift when users edit their number or when numbering plans evolve.
International dialing prefixes are not part of E.164 but appear in user input. For example, a user in the US might dial 011 44 20 7946 0958 to reach London, while a user in Europe might dial 00 1 415 555 2671 to reach San Francisco. Your parsing logic should strip these prefixes and retain only the country code and national number.
Users often mix local and international formats. That is why you should accept a broad set of input styles and normalize internally. Rejecting a number because it does not match a strict formatting mask is a common source of failed signups.
A robust validation pipeline accepts multiple input styles but stores a single normalized form. This avoids data quality problems when you later integrate with SMS, voice, or verification services.
Many services require E.164 input for outbound messages and calls. If your application validates only the local format, you may still fail when you hand the value to a provider. Always validate at the E.164 level and store the normalized output, then map it back for display.
When testing, include numbers from multiple regions and service types (mobile, landline, toll-free). This ensures your formatting and validation logic handles realistic datasets.
+1 415 555 2671
United States
+44 20 7946 0958
United Kingdom
+81 3 1234 5678
Japan
+86 10 8888 6666
China
These examples are formatted for readability. Your backend should store the same numbers in strict E.164 (for example, +14155552671) while rendering a localized version for UI.
If you need test data, try the phone number generator or the bulk generator. For validation, use the validator to verify format rules before storing data.