phone number standards
phone number standards
Tanzania Phone Numbers: Format, Area Code & Validation Guide
Complete guide to Tanzania phone number formats, validation, and mobile operators. Learn country code +255, E.164 compliance, MNP regulations, and implementation best practices with code examples.
Tanzania Phone Numbers: Format, Area Code & Validation Guide
Introduction
Build applications that handle Tanzanian phone numbers correctly. This comprehensive guide covers Tanzania country code +255, phone number structure, validation regex patterns, and best practices for integrating with Tanzania's telecommunications system – from basic E.164 formats to Mobile Number Portability (MNP) and TCRA regulatory requirements.
Who should read this: Developers building messaging platforms, authentication systems, contact management tools, or any application that stores or validates Tanzanian phone numbers.
Common use cases: SMS delivery, two-factor authentication, CRM systems, payment gateways, and telecom integrations.
Quick Reference
Key identifiers for Tanzanian phone numbers:
- Country: Tanzania
- Country Code: +255
- International Prefix: 00[056] (Variations exist; 000 is the most common)
- National Prefix: 0
- National Significant Number (NSN): 9 digits
Sources: ITU-T E.164 Standard; ITU Tanzania Numbering Plan
Understand the Tanzanian Phone Numbering System
Tanzania's telephone numbering system follows the international E.164 standard (ITU-T Recommendation E.164). This standard ensures your application can handle phone numbers consistently across borders.
Why E.164 matters for developers: E.164 defines a maximum of 15 digits and requires a structured format (country code + national number). This standardization enables your database schemas to be predictable, your APIs to validate input reliably, and your routing logic to work correctly across international networks. Store all numbers in E.164 format (+255XXXXXXXXX) to avoid formatting inconsistencies and enable seamless international dialing.
Each Tanzanian phone number consists of:
- Country Code (+255): Uniquely identifies Tanzania in the global telecommunications network.
- National Significant Number (9 digits): Identifies the specific subscriber or service.
- National Prefix (0) (for domestic dialing): Used when dialing within Tanzania. Omit when dialing internationally.
Source: Telephone numbers in Tanzania - Wikipedia
Number Formats in Detail
Tanzania uses different number ranges for specific services. Validate against the correct pattern based on your application's needs:
| Type of Number | Format | Example Numbers | Description |
|---|---|---|---|
| Geographic Numbers | 2[2-8]XXXXXXX | 222123456, 288765432 | Landline numbers for fixed-line telephony, associated with specific geographic areas. |
| Mobile Numbers | 6[125-9]XXXXXXX, 7[13-9]XXXXXXX | 621234567, 713456789 | Numbers used by mobile operators. The prefixes indicate the original assigned operator, but numbers can be ported. |
| Toll-Free Numbers | 80[08]XXXXXX | 800123456, 808654321 | National and international toll-free services. Calls are free for the caller. |
| Premium Numbers | 90XXXXXXX | 901234567, 902345678 | Premium-rate services for special content or services. Calls incur higher charges. |
| Shared Cost Numbers | 840XXXXXX, 86[01]XXXXXX | 840123456, 860987654 | Shared cost services where the cost is split between caller and recipient. |
| Emergency Numbers | 11[12], 999 | 111, 112, 999 | Emergency services (Police, Fire, Ambulance). Important: 112 doesn't work consistently outside Dar es Salaam, and there are no government-provided ambulance services in Tanzania. |
Geographic area codes: The second digit (2-8) in landline numbers indicates the region. For example, 22 is Dar es Salaam, 25 is Mwanza, and 27 is Arusha.
Sources: ITU Tanzania Numbering Plan; Emergency Numbers Tanzania
Implement Tanzania Phone Number Validation
Validate Tanzanian phone numbers to ensure data integrity and prevent routing errors. These examples demonstrate regex validation patterns and core validation logic with error handling:
JavaScript Validation for Tanzania Numbers
const validateTanzanianNumber = (phoneNumber) => {
// Remove any spaces or special characters for consistent validation.
const cleanNumber = phoneNumber.replace(/\D/g, '');
// Patterns for different number types using regular expressions.
const patterns = {
geographic: /^2[2-8]\d{7}$/,
mobile: /^(?:6[125-9]|7[13-9])\d{7}$/,
tollFree: /^80[08]\d{6}$/,
premium: /^90\d{7}$/,
sharedCost: /^(?:840|86[01])\d{6}$/,
emergency: /^(?:11[12]|999)$/
};
// Check if the number matches any valid pattern.
return Object.values(patterns).some(pattern => pattern.test(cleanNumber));
};
// Example usage
console.log(validateTanzanianNumber("+255711234567")); // true - Valid mobile number
console.log(validateTanzanianNumber("221234567")); // true - Valid geographic number (national format)
console.log(validateTanzanianNumber("00255711234567")); // true - Valid mobile number (international format)
console.log(validateTanzanianNumber("+2551234567890")); // false - Invalid number (too many digits)
console.log(validateTanzanianNumber("123")); // false - Invalid number (too few digits)Production recommendations: Use libraries like google-libphonenumber or awesome-phonenumber for comprehensive validation. These libraries handle international prefixes, formatting variations, and edge cases automatically. For high-volume applications, cache validation results and consider rate limiting to prevent abuse.
Python Validation for Tanzania Numbers
import re
def validate_tanzania_number(phone_number: str) -> tuple[bool, str]:
"""
Validates Tanzanian phone numbers and identifies their type.
Args:
phone_number (str): Phone number to validate
Returns:
tuple[bool, str]: (is_valid, number_type)
"""
patterns = {
'geographic': r'^2[2-8]\d{7}$',
'mobile': r'^(?:6[125-9]|7[13-9])\d{7}$',
'toll_free': r'^80[08]\d{6}$',
'premium': r'^90\d{7}$',
'shared_cost': r'^(?:840|86[01])\d{6}$',
'emergency': r'^(?:11[12]|999)$'
}
# Standardize input format to handle variations in prefixes and spacing.
cleaned_number = phone_number.replace('+255', '').replace(' ', '').strip()
if cleaned_number.startswith('0'):
cleaned_number = cleaned_number[1:]
# Validate against patterns.
for number_type, pattern in patterns.items():
if re.match(pattern, cleaned_number):
return True, number_type
return False, None
# Example usage
print(validate_tanzania_number("+255651234567")) # Output: (True, 'mobile')
print(validate_tanzania_number("0757123456")) # Output: (True, 'mobile')
print(validate_tanzania_number("800123456")) # Output: (True, 'toll_free')
print(validate_tanzania_number("invalid_number")) # Output: (False, None)Production recommendations: Use phonenumbers library for robust validation:
import phonenumbers
from phonenumbers import carrier, geocoder
try:
parsed = phonenumbers.parse("+255712345678", None)
is_valid = phonenumbers.is_valid_number(parsed)
number_type = phonenumbers.number_type(parsed)
operator = carrier.name_for_number(parsed, "en")
except phonenumbers.NumberParseException as e:
print(f"Invalid number: {e}")Handle null/empty inputs explicitly to prevent runtime errors:
if not phone_number or not isinstance(phone_number, str):
return False, "Invalid input"Tanzania Mobile Network Operators
Know the major mobile operators and their number prefixes for accurate routing and integration planning:
| Operator | Number Ranges | Market Position & Services |
|---|---|---|
| Vodacom Tanzania | +255 74, +255 75, +255 76 | Market leader with comprehensive coverage and advanced 4G/5G services. |
| Airtel Tanzania | +255 68, +255 69, +255 78 | Strong data service provider with competitive pricing. |
| Tigo | +255 65, +255 67, +255 71 | Known for innovation in mobile financial services. Merged with Zantel in 2019. |
| Halotel | +255 61, +255 62 | Focuses on expanding rural coverage with affordable packages. Over 85% population coverage. |
| Zantel | +255 77 | Formerly a Zanzibar specialist, merged with Tigo in 2019, expanding combined reach. |
| Smile | +255 66 | 4G data specialist focusing on urban areas. |
| TTCL | +255 73 | The incumbent national operator offering mobile services. Also operates fixed-line services using 2X area codes. |
Operator integration: Contact operator business development teams for API access. Most operators provide SMS gateway APIs, USSD integration, and mobile money APIs. Check each operator's developer portal for documentation and onboarding requirements.
Sources: List of mobile network operators in Tanzania - Wikipedia; Tanzania Mobile Operators 2025
As of June 2023, Vodacom, Airtel, and Tigo (now merged with Zantel) dominate the market, collectively holding the lion's share of mobile subscriptions. This information is valuable when considering market reach and potential integration with specific operators. These number ranges represent the original assigned operator. Due to Mobile Number Portability (MNP), a number might be used by a different operator than the one originally assigned.
Important clarification: The Tigo-Zantel merger completed in 2019. In April 2022, the combined entity (MIC Tanzania Limited) was sold to a consortium led by AXIAN Telecom and Mr. Rostam Azizi for $100 million, bringing approximately 14 million mobile customers to AXIAN Telecom.
Source: Tanzania Mobile Operators Complete Merger - TanzaniaInvest
Understand Mobile Number Portability (MNP)
MNP allows subscribers to switch operators while keeping their existing phone numbers. Number prefixes no longer reliably indicate the current operator.
Implement MNP Lookup
Integrate with a number portability database to determine the current operator:
Option 1: TCRA Central Reference Database
- Contact TCRA for access to their MNP database
- Real-time lookup via API or batch file updates
- Authoritative source for all ported numbers
Option 2: Third-party APIs
- Services like Twilio, Infobip, or Africa's Talking provide MNP lookup
- Include operator information in their APIs
- Easier integration but may have usage fees
Implementation approach:
async function getCurrentOperator(phoneNumber) {
try {
const response = await fetch(`https://api.example.com/mnp/lookup?number=${phoneNumber}`);
const data = await response.json();
return data.current_operator; // Returns actual operator, not prefix-based assumption
} catch (error) {
console.error('MNP lookup failed:', error);
// Fall back to prefix-based detection with warning
return getPrefixBasedOperator(phoneNumber);
}
}Cache lookup results with appropriate TTL (e.g., 24 hours) to reduce API calls and improve performance.
MNP Implementation: Mobile number portability in Tanzania officially started on March 1 (implementation occurred around 2016–2023, with various sources citing different dates). Over 40 million Tanzanians can switch networks without changing their mobile numbers, and this service is offered free of charge.
Porting timeline: Number porting typically completes within 3-5 business days. During porting, numbers may experience temporary service interruptions. Build retry logic into your application to handle transient failures during the porting window.
Source: TCRA Mobile Number Portability
Plan Your Technical Architecture
Design systems that handle Tanzania's growing mobile market:
Scalability requirements:
- Plan for 1,000+ requests per second during peak hours
- Use distributed caching (Redis, Memcached) for number validation results
- Implement database partitioning by number prefix for faster lookups
- Queue-based processing for bulk operations (RabbitMQ, AWS SQS)
Compliance checklist:
- Store numbers in E.164 format (+255XXXXXXXXX)
- Log all number lookups for TCRA audit requirements
- Implement data retention policies per TCRA guidelines
- Support MNP by avoiding hardcoded operator mappings
- Review TCRA technical specifications at https://tcra.go.tz/
Technology stack recommendations:
- Number validation: phonenumbers library (Python), libphonenumber (Java/JavaScript)
- MNP lookup: Integrate TCRA database or third-party API
- Storage: PostgreSQL with btree indexes on phone number fields
- Caching: Redis with 24-hour TTL for operator lookups
- Monitoring: Track validation failure rates, MNP lookup latency, and operator routing accuracy
Cloud deployment patterns:
- AWS: Lambda for validation, DynamoDB for number metadata, API Gateway for REST endpoints
- Azure: Functions for processing, Cosmos DB for global distribution, Front Door for routing
- GCP: Cloud Functions for validation, Firestore for flexible schemas, Cloud CDN for caching
Implement health checks for external dependencies (MNP databases, operator APIs) with automatic failover to cached data.
Navigate the Legal and Regulatory Framework
Comply with Tanzania's telecommunications legal framework:
Key legislation:
- Tanzania Communication Regulatory Authority Act (2003): Establishes TCRA's authority
- Electronic and Postal Communications Act (EPOCA 2010, revised 2022): Governs licensing and operations
- Universal Communications Service Access Act (2006): Ensures service accessibility
Compliance requirements for developers:
- Data Privacy: Store phone numbers securely with encryption at rest and in transit
- User Consent: Obtain explicit opt-in consent before sending marketing messages
- Data Retention: Implement policies compliant with TCRA guidelines
- Local Presence: Some license types require local shareholding (consult legal counsel)
Application licensing:
- SMS aggregators: Require TCRA content provider license
- VoIP services: Need specialized telecommunications license
- Basic validation/storage: No license required, but data protection rules apply
Penalties for violations:
- Unauthorized telecommunications services: Fines up to TZS 100 million
- Privacy violations: Civil and criminal penalties under EPOCA
- Spam/unsolicited messages: Per-message fines and potential service suspension
Contact TCRA (info@tcra.go.tz) for licensing inquiries or visit https://tcra.go.tz/services for guidance.
Conclusion
You now have the knowledge to handle Tanzanian phone numbers correctly in your applications. Validate numbers properly, implement MNP lookup for accurate routing, and comply with TCRA regulations. Monitor TCRA announcements for regulatory updates that may affect your implementation.
Frequently Asked Questions About Tanzania Phone Numbers
What is Tanzania country code for phone numbers?
+255 is the Tanzania country code. When dialing internationally, use +255 followed by the 9-digit national number (omit the leading 0 used for domestic dialing). Tanzania follows the ITU-T E.164 international standard. Example: A mobile number displayed domestically as 0712 345 678 becomes +255 712 345 678 internationally.
How to validate Tanzania phone numbers with regex?
Use the regex pattern ^(?:6[125-9]|7[13-9])\\d{7}$ for validating 9-digit mobile numbers in national format (without the 0 prefix). Mobile numbers start with prefixes 61, 62, 65, 67, 68, 69, 71, 73, 74, 75, 76, 77, or 78. For international format validation, use ^(\\+255|255)?(?:6[125-9]|7[13-9])\\d{7}$. Remove spaces and special characters before validation.
What mobile network operators serve Tanzania?
Tanzania has 7 major operators: Vodacom Tanzania (prefixes 74, 75, 76), Airtel Tanzania (68, 69, 78), Tigo (65, 67, 71), Halotel (61, 62), Zantel (77), Smile (66), and TTCL (73). Vodacom leads with comprehensive 4G/5G coverage. Tigo merged with Zantel in 2019; the combined entity was sold to AXIAN Telecom in 2022. Mobile Number Portability allows subscribers to keep numbers when switching operators.
What are the emergency numbers in Tanzania?
111, 112, and 999 (Police, Fire, Ambulance). Critical limitation: 112 doesn't work consistently outside Dar es Salaam, and there are no government-provided ambulance services. Include warnings about these limitations in your application and provide alternative emergency contacts for rural areas.
What is the format for Tanzania geographic (landline) phone numbers?
2[2-8]\\d{7} – starts with "2" followed by a digit from 2-8, then 7 additional digits (9 digits total). Examples: 222 123 456 or 288 765 432. International format: +255 followed by the 9-digit number (+255 222 123 456). Regex: ^2[2-8]\\d{7}$. These are fixed-line numbers associated with specific geographic areas.
How does Mobile Number Portability (MNP) work in Tanzania?
MNP allows subscribers to switch operators while keeping their numbers. Implementation began March 1 (2016-2023), is free, and covers 40+ million Tanzanians. TCRA manages MNP. Critical for developers: Don't rely on number prefixes to identify the current operator. Implement real-time operator lookup using a number portability database or API for correct routing.
What is the National Significant Number (NSN) length for Tanzania?
9 digits for all phone types (mobile, landline, toll-free, premium). International format follows E.164 with max 15 digits: +255 (country code) + 9-digit NSN. Domestic dialing adds "0" prefix (10 digits total).
What are Tanzania toll-free and premium number formats?
Toll-free: 80[08]\\d{6} (e.g., 800 123 456) – free for callers, recipient pays. Premium: 90\\d{7} (e.g., 901 234 567) – higher rates for special content/services. Shared cost: 840\\d{6} or 86[01]\\d{6} – costs split between caller and recipient. All use 9-digit NSN.
What regulatory authority governs Tanzania telecommunications?
Tanzania Communications Regulatory Authority (TCRA) governs all telecommunications. TCRA manages the National Numbering Plan, oversees MNP, enforces technical specifications, and ensures consumer protection. Legal framework: TCRA Act (2003), Electronic and Postal Communications Act (EPOCA 2010, revised 2022), and Universal Communications Service Access Act (2006). Comply with TCRA regulations when building telecom applications.
How to format Tanzania phone numbers correctly?
Use 3-3-3 grouping with spaces for display: Mobile: 712 345 678, Landline: 222 123 456, Toll-free: 800 123 456, International: +255 712 345 678. Domestic display includes "0" prefix: 0712 345 678. Store numbers in E.164 format (+255712345678) in databases for consistency and international compatibility.