phone number standards

Sent logo
Sent TeamMar 8, 2026 / phone number standards / Article

Morocco Phone Numbers: +212 Country Code Format & Validation Guide

Learn Morocco's +212 country code, phone number format (10-digit with 0, 9-digit international), validation patterns, mobile prefixes (06/07), area codes, and ANRT regulations for developers.

Morocco Phone Numbers: Format, Area Code & Validation Guide

Morocco uses country code +212 with a 10-digit domestic format (starting with 0) or 9-digit international format. This guide covers validation patterns, mobile prefixes (06/07), area codes for major cities, ANRT regulations, emergency numbers, VoIP integration, and number portability implementation for developers building telecommunications applications.

Morocco Country Code: +212 Dialing System Explained

Morocco's country code is +212. The telephone numbering system, regulated by the National Telecommunications Regulatory Agency (ANRT), uses a closed numbering plan requiring the full 10-digit number for all domestic calls (starting with 0) or 9 digits for international format (after +212). Multiple prefixes can serve the same geographic area—Casablanca has 10 different prefixes across operators.

Validation Examples:

javascript
// Basic Morocco number validation
function validateMoroccoNumber(number) {
  // Domestic format: 10 digits starting with 0
  const domesticPattern = /^0[2567][0-9]{8}$/;
  // International format: +212 followed by 9 digits
  const internationalPattern = /^\+212[2567][0-9]{8}$/;

  // Remove spaces, hyphens, parentheses for validation
  const cleaned = number.replace(/[\s\-\(\)\.]/g, '');

  if (domesticPattern.test(cleaned)) {
    return {
      valid: true,
      format: 'domestic',
      type: getNumberType(cleaned)
    };
  } else if (internationalPattern.test(cleaned)) {
    return {
      valid: true,
      format: 'international',
      type: getNumberType(cleaned.slice(4)) // Remove +212
    };
  }

  return { valid: false, reason: 'Invalid format' };
}

function getNumberType(number) {
  const prefix = number.slice(0, 2);
  if (prefix === '06' || prefix === '07') return 'mobile';
  if (prefix === '05') return 'urban_landline';
  if (prefix === '02') return 'rural_landline';
  if (prefix === '08') return 'special_service';
  return 'unknown';
}

// Test cases
console.log(validateMoroccoNumber('0612345678'));      // Valid mobile
console.log(validateMoroccoNumber('+212 612 345 678')); // Valid international
console.log(validateMoroccoNumber('0520123456'));      // Valid Casablanca landline
console.log(validateMoroccoNumber('061234567'));       // Invalid - wrong length
console.log(validateMoroccoNumber('0812345678'));      // Valid special service

Source: ANRT National Numbering Plan; ITU Telephone numbers in Morocco

Domestic Calling Essentials

Understand these domestic calling rules to ensure your applications correctly handle local calls within Morocco.

Standard Calling Rules

  • Always use the complete 10-digit number format: This includes the leading '0' and the area code.
  • Include the leading '0' for all domestic calls: This distinguishes domestic calls from international ones.
  • Area codes are mandatory nationwide: These codes identify the geographic region and sometimes the service provider.
  • Spacing is optional but recommended for readability: For example, 05 20 12 34 56 improves visual clarity.

Best Practice: Store numbers in your system with the '+212' prefix. This international format ensures compatibility for both domestic and international calls, simplifying your data management.

Regional Considerations

Morocco's numbering structure varies by region and service type:

  • Urban Areas: Primarily use the 05 prefix for landlines. Landline numbers follow the structure 05ZABPQMCDU, where the digits after 05 represent the regional area (RR) and local area (LL), followed by the subscriber number. Multiple prefixes can exist within a single urban area—for example, Casablanca has 10 different prefixes, each potentially belonging to different operators.
  • Rural/Southern Areas: May use the 02 prefix for landlines in certain regions. The 02 prefix generally covers southern areas of Morocco.
  • Mobile Networks: Use the 06 and 07 prefixes nationwide. Mobile numbers follow the structure 0ABPQMCDU, where A takes the value 6 or 7 for currently active mobile services. This consistent prefix pattern simplifies mobile number identification and processing across all geographic regions.

Note: Morocco's closed numbering plan requires dialing the complete 10-digit number even for local calls because the same geographic area can be served by multiple prefixes across different operators.

Morocco Area Codes for Major Cities

CityArea CodeFull PrefixExample Format
Casablanca522-5290520-05290522 12 34 56
Rabat53705370537 12 34 56
Marrakech52405240524 12 34 56
Fes53505350535 12 34 56
Tangier53905390539 12 34 56
Meknes53505350535 12 34 56
Oujda53605360536 12 34 56
Agadir52805280528 12 34 56
Tetouan53905390539 12 34 56
Kenitra53705370537 12 34 56

Note: Major cities may have multiple area codes. For instance, Casablanca uses codes from 0522 through 0529 across different operators and districts.

Source: ANRT National Numbering Plan; Telephone numbers in Morocco (ITU standards)

How to Call Morocco Internationally

Handle international calls with specific procedures for both dialing from and into Morocco.

Calling From Morocco

To call internationally from Morocco:

  1. Dial the international prefix: 00
  2. Enter the country code: For example, 33 for France or 1 for the United States
  3. Dial the local number without its leading zero (if applicable): Each country has its own numbering conventions

Example: Calling France (33)

plaintext
00 33 1 23 45 67 89  # French number format

Calling Into Morocco from Abroad

To call Morocco from another country:

  1. Use the country code: +212
  2. Omit the leading '0' from the Moroccan number: Use the remaining 9 digits

Example: International format for Moroccan numbers

plaintext
+212 520 123 456  # Landline
+212 612 345 678  # Mobile

Key Detail: All Moroccan numbers are 9 digits long (excluding the leading '0'). This consistent length simplifies validation and processing.

Format Conversion Examples

javascript
// Convert domestic to international format
function domesticToInternational(domestic) {
  if (!/^0[2567][0-9]{8}$/.test(domestic)) {
    return { error: 'Invalid domestic format' };
  }
  return '+212' + domestic.slice(1);
}

// Convert international to domestic format
function internationalToDomestic(international) {
  const cleaned = international.replace(/[\s\-\(\)\.]/g, '');
  if (!/^\+?212[2567][0-9]{8}$/.test(cleaned)) {
    return { error: 'Invalid international format' };
  }
  const digits = cleaned.replace(/^\+?212/, '');
  return '0' + digits;
}

// Handle common formatting errors
function normalizeNumber(input) {
  // Remove all non-digit characters except leading +
  let cleaned = input.replace(/[^\d+]/g, '');

  // Handle common errors
  if (cleaned.startsWith('00212')) {
    cleaned = '+212' + cleaned.slice(5);
  } else if (cleaned.startsWith('212') && !cleaned.startsWith('+')) {
    cleaned = '+' + cleaned;
  }

  return cleaned;
}

// Examples
console.log(domesticToInternational('0612345678'));     // +212612345678
console.log(internationalToDomestic('+212 612 345 678')); // 0612345678
console.log(normalizeNumber('00212-612-345-678'));      // +212612345678
console.log(normalizeNumber('212 612 345 678'));        // +212612345678

Common Formatting Errors:

  • Using 00212 instead of +212 (both valid, but + is standard)
  • Including the leading 0 in international format (incorrect)
  • Wrong digit count (must be 9 after +212, or 10 with leading 0)
  • Invalid prefixes (must start with 2, 5, 6, or 7 after country code)

Emergency and Special Service Numbers

Ensure your applications correctly handle emergency and special service numbers so users can access critical services.

Emergency Services Network

ServiceNumberAvailabilityNotes
Police19024/7Also 112 from mobile phones
Royal Gendarmerie17724/7Military police
Ambulance/Fire15024/7Combined emergency service
Civil Protection15024/7Same as Ambulance/Fire

Important: Emergency numbers are toll-free and function without a SIM card or credit balance. Note that 911 does not work in Morocco—always use the local emergency numbers listed above.

Source: UK Government Foreign Travel Advice for Morocco (accessed August 2025); ANRT emergency services guidance

Special Service Numbers

Access various services through these numbers with specific dialing patterns:

  1. Toll-Free Services (080): Customer service lines, government helplines, and public information services. Free from fixed telephone networks but may incur surcharges when calling from mobile lines.
  2. Premium Services (089): Professional consulting, entertainment services, and specialized information lines. Premium-rate services include gaming, ringtone downloads, and other paid content. Pricing varies by service; users are charged per minute or per call at rates significantly higher than standard calls.
  3. Short Codes (3-5 digits): Utility services, banking services, operator assistance, weather updates, government information, and social services. Each operator and service uses specific short codes.

Common Short Codes:

ServiceShort CodeOperatorNotes
Customer Service121Orange MoroccoCustomer support
Customer Service120INWICustomer support
Customer Service555Maroc TelecomNumber inquiry, customer service
Balance Check#111#Maroc TelecomCheck account balance
Balance Check*100#Orange MoroccoCheck account balance
Balance Check*100#INWICheck account balance

Pricing Notes:

  • Toll-free (080): Free from landlines; mobile operators may charge standard rates
  • Premium (089): Typically 1-5 MAD per minute; check with service provider
  • Short codes: Usually free or charged at local SMS/call rates

Source: ANRT Special Numbers guidance (accessed January 2025); HelloDuty Morocco Services

Morocco VoIP Regulations and Integration

Integrate VoIP services with careful consideration of Moroccan regulations and number formats.

VoIP Regulation Status

Important Update: Morocco lifted its VoIP service ban in February 2022. Previously restricted since January 2016, VoIP services including WhatsApp calls, Skype, and other Voice over Internet Protocol applications are now legally permitted.

Regulatory Context: The ANRT reversed earlier restrictions based on evaluation of the national and international telecom market, legal context, and consumer implications. This liberalization aligns with Morocco's Digital Morocco Plan 2025-2030, which aims to improve internet access and stimulate ICT entrepreneurship.

Source: ANRT official announcements (February 2022); Digital Watch Observatory

VoIP Integration Guidelines

Licensing Requirements:

  • Commercial VoIP Providers: Must hold a license under ANRT/DG/N° 04-04 (April 6, 2004) for public IP telephony services
  • Call Centers: May use IP telephony only for "online information" services; traffic must be carried by licensed ERPT operators
  • Private Networks: Can use IP telephony for internal/private use without licensing
  • Individual Users: No license required for personal use of VoIP services (WhatsApp, Skype, etc.)

Technical Implementation:

  • Use authorized VoIP services: While VoIP is now permitted, ensure compliance with ANRT regulations and licensing requirements where applicable
  • Support Moroccan number formats: Your VoIP application must correctly handle both domestic and international formats
  • Configure for international format (+212): This ensures consistent behavior across different call scenarios
javascript
// VoIP number formatting for Morocco
function formatForVoIP(number) {
  const cleaned = number.replace(/[\s\-\(\)\.]/g, '');

  // Convert to international format for VoIP
  if (cleaned.startsWith('0') && cleaned.length === 10) {
    return 'sip:+212' + cleaned.slice(1) + '@voip.provider.com';
  } else if (cleaned.startsWith('+212')) {
    return 'sip:' + cleaned + '@voip.provider.com';
  }

  return { error: 'Invalid number format' };
}

// Example
console.log(formatForVoIP('0612345678'));
// Returns: sip:+212612345678@voip.provider.com

Tip: Some VoIP services require specific configurations for optimal performance in Morocco. Consult your provider's documentation for details. Test your VoIP implementation thoroughly to ensure reliable communication.

Source: ANRT Telephony Regulations

Morocco Number Portability: How to Switch Operators

Understand how number portability – switching operators while retaining your number – impacts your applications.

Overview and Recent Developments

Morocco's number portability system has significantly improved through ANRT's commitment to consumer choice:

  • One-Day Porting: Porting completes within one business day. ANRT implemented this reduction in April 2024, shortening the deadline from two days to enhance competition among telecom operators (Maroc Telecom, Inwi, and Orange). Previously, in January 2020, ANRT reduced processing time from three days to two days. Consider this crucial timeline when implementing number portability features.
  • Zero-Cost Implementation: Porting is free for all subscribers, encouraging market mobility
  • Universal Availability: The service covers all operators and number types
  • Strong Oversight: ANRT actively monitors the system to ensure quality and compliance
  • Porting Authorization Code: ANRT introduced a Porting Authorization Code (Relevé d'Identité Opérateur – RIO), an identifier each operator assigns to their customer's call number, facilitating easier number portability

Sources: Ecofin Agency (April 2024); ANRT official communications

Implementation Framework

The porting process follows a streamlined workflow:

  1. Subscriber Request: The subscriber submits a request to their new operator, providing identification and their current number.
  2. Operator Processing: The new operator verifies eligibility, notifies the current operator, and coordinates database updates.
  3. Service Migration: The number is ported at a scheduled time, followed by service testing and customer notification.

Eligibility Requirements:

  • Valid Identification: Government-issued ID or passport
  • Current Number Ownership: Must be the registered owner of the number
  • No Outstanding Debts: Account must be in good standing with current operator
  • Geographic Compatibility: For landlines, new operator must serve the same geographic area code
  • Active Service: Number must be active (not suspended or cancelled)

Required Documents:

  • National ID card (CNIE) or passport
  • Proof of address (utility bill or rental agreement) for landline portability
  • RIO code from current operator (obtained by calling customer service)
  • Signed portability request form at new operator's office

Service Interruption: Porting typically occurs overnight (during low-traffic hours). Expect a brief service interruption of 2-4 hours during the transition. ANRT mandates that interruptions should not exceed 4 hours.

Rollback Procedures: If porting fails, the number automatically reverts to the original operator within 24 hours. Subscribers are notified by SMS. No charges apply for failed porting attempts.

Source: ANRT Telephony Regulations

Technical Implementation Guidelines

Integrate number portability into your systems with these considerations:

  • Validation: Verify the number format and eligibility for porting
  • Timing: Account for the one-day porting timeframe in your application logic
  • ANRT Developer Portal: Refer to the ANRT Developer Portal for the latest technical specifications and implementation details
javascript
// Number portability validation check
function validatePortingEligibility(phoneNumber) {
  // Check number format (supports both 06 and 07 prefixes for mobile)
  const numberPattern = /^0[6-7][0-9]{8}$/;
  if (!numberPattern.test(phoneNumber)) {
    return {
      eligible: false,
      reason: 'Invalid number format'
    };
  }

  // Placeholder for additional validation logic (e.g., checking against a portability database)
  // ...

  return {
    eligible: true,
    estimatedPortingTime: '24h'
  };
}

// Test cases
console.log(validatePortingEligibility('0612345678')); // Valid mobile number
console.log(validatePortingEligibility('0712345678')); // Valid mobile number
console.log(validatePortingEligibility('0512345678')); // Invalid – landline, not eligible for this example
console.log(validatePortingEligibility('061234567'));  // Invalid – incorrect length

Real-World Implementation: Integrate with a portability database or API to confirm eligibility. Consider edge cases such as temporarily unavailable numbers during the porting process. Implement retry mechanisms or provide informative error messages to users. Incorporate the ANRT Porting Authorization Code (RIO) into your validation process.

Source: ANRT

Troubleshooting

Solve common issues encountered when working with Moroccan phone numbers.

Common Issues and Solutions

Failed Domestic Calls:

  • Symptom: Call doesn't connect or displays "invalid number"
  • Diagnostic Steps:
    1. Verify 10-digit format with leading '0'
    2. Check prefix is valid (02, 05, 06, 07, 08)
    3. Confirm area code matches recipient's location for landlines
    4. Test with another number to isolate issue
  • Solutions: Ensure complete number format; verify network coverage in recipient's area; check caller's balance/plan

International Call Problems:

  • Symptom: "Cannot complete call" or "invalid destination"
  • Diagnostic Steps:
    1. Confirm international calling is activated on account
    2. Verify correct country code format (+212, not 00212 in some systems)
    3. Check that leading '0' is removed from Moroccan number
    4. Test with known valid international number
  • Solutions: Contact operator to activate international calling; use correct +212 format; verify sufficient calling credit

VoIP Connectivity Issues:

  • Symptom: Poor call quality, dropped calls, or connection failures
  • Diagnostic Steps:
    1. Test internet speed (minimum 1 Mbps for voice)
    2. Check VoIP app has required permissions (microphone, network)
    3. Verify firewall/NAT settings don't block VoIP ports
    4. Test on different network (WiFi vs mobile data)
  • Solutions: Switch to stronger WiFi; ensure VoIP app is updated; configure router for VoIP traffic; check operator for VoIP restrictions

Validation Errors in Code:

javascript
// Common validation error handling
function validateWithErrors(number) {
  const errors = [];
  const cleaned = number.replace(/[\s\-\(\)\.]/g, '');

  // Check length
  if (cleaned.startsWith('0') && cleaned.length !== 10) {
    errors.push({
      code: 'INVALID_LENGTH',
      message: 'Domestic format requires exactly 10 digits',
      received: cleaned.length
    });
  } else if (cleaned.startsWith('+212') && cleaned.length !== 13) {
    errors.push({
      code: 'INVALID_INTL_LENGTH',
      message: 'International format requires +212 followed by 9 digits',
      received: cleaned.length
    });
  }

  // Check prefix
  const prefix = cleaned.startsWith('0') ? cleaned.slice(0, 2) : cleaned.slice(4, 6);
  if (!['02', '05', '06', '07', '08'].includes(prefix)) {
    errors.push({
      code: 'INVALID_PREFIX',
      message: 'Number must start with 02, 05, 06, 07, or 08',
      received: prefix
    });
  }

  // Check format
  if (!cleaned.startsWith('0') && !cleaned.startsWith('+212')) {
    errors.push({
      code: 'INVALID_FORMAT',
      message: 'Number must start with 0 (domestic) or +212 (international)'
    });
  }

  return {
    valid: errors.length === 0,
    errors: errors,
    debugInfo: {
      original: number,
      cleaned: cleaned,
      detectedPrefix: prefix
    }
  };
}

// Example usage
console.log(validateWithErrors('061234567'));  // Shows INVALID_LENGTH error
console.log(validateWithErrors('0812345678')); // Valid
console.log(validateWithErrors('0412345678')); // Shows INVALID_PREFIX error

Operator Technical Support Contacts:

OperatorCustomer ServiceTechnical SupportOnline Support
Maroc Telecom555 or 080 100 8000+212 537 71 90 00support_MT@iam.ma
Orange Morocco121+212 801 00 00 00Via website chat
INWI120+212 529 00 00 00Via mobile app

For Persistent Issues: Direct users to contact their service provider's technical support with account details ready. Provide error codes and diagnostic information from your validation functions to speed resolution.

Sources: Maroc Telecom Contact; Morocco Mobile Network USSD Codes

Frequently Asked Questions

What is Morocco's country code for phone numbers?

Morocco's international country code is +212. When calling Morocco from abroad, dial +212 followed by the 9-digit Moroccan number (omit the leading '0'). Example: To call Moroccan mobile 0612345678 internationally, dial +212 612 345 678. The 212 country code distinguishes Morocco from other nations in the global telephone network.

How many digits is a Moroccan phone number?

Moroccan phone numbers are 10 digits for domestic format and 9 digits for international format (after country code +212). Domestic format: 0X XX XX XX XX starts with '0', followed by prefix (05 urban landlines, 02 rural landlines, 06/07 mobile), then subscriber number. International format: +212 X XX XX XX XX (9 digits after +212, no leading '0').

How do I validate a Morocco phone number?

Use this regex pattern for basic validation: /^0[2567][0-9]{8}$/ for domestic format or /^\+212[2567][0-9]{8}$/ for international format. Ensure the number is exactly 10 digits (domestic) or 9 digits after +212 (international). Mobile numbers start with 06 or 07, landlines with 02 or 05.

Complete validation function:

python
import re

def validate_morocco_number(number):
    """
    Validate Morocco phone numbers in multiple formats.
    Returns dict with validation result and details.
    """
    # Remove common separators
    cleaned = re.sub(r'[\s\-\(\)\.]', '', number)

    # Patterns
    domestic = re.compile(r'^0[2567][0-9]{8}$')
    international = re.compile(r'^\+212[2567][0-9]{8}$')

    if domestic.match(cleaned):
        prefix = cleaned[0:2]
        number_type = {
            '06': 'mobile', '07': 'mobile',
            '05': 'urban_landline', '02': 'rural_landline',
            '08': 'special_service'
        }.get(prefix, 'unknown')

        return {
            'valid': True,
            'format': 'domestic',
            'type': number_type,
            'formatted': f"{cleaned[0:4]} {cleaned[4:6]} {cleaned[6:8]} {cleaned[8:10]}"
        }

    elif international.match(cleaned):
        prefix = cleaned[4:6]
        number_type = {
            '6': 'mobile', '7': 'mobile',
            '5': 'urban_landline', '2': 'rural_landline',
            '8': 'special_service'
        }.get(prefix[0], 'unknown')

        return {
            'valid': True,
            'format': 'international',
            'type': number_type,
            'formatted': f"+212 {cleaned[4:7]} {cleaned[7:9]} {cleaned[9:11]} {cleaned[11:13]}"
        }

    return {
        'valid': False,
        'error': 'Invalid format or prefix',
        'cleaned': cleaned
    }

# Examples
print(validate_morocco_number('0612345678'))
print(validate_morocco_number('+212 612 345 678'))
print(validate_morocco_number('0520-12-34-56'))

Other Languages:

java
// Java validation
public static boolean isValidMoroccoNumber(String number) {
    String cleaned = number.replaceAll("[\\s\\-\\(\\)\\.]", "");
    return cleaned.matches("^0[2567][0-9]{8}$") ||
           cleaned.matches("^\\+212[2567][0-9]{8}$");
}
php
// PHP validation
function validateMoroccoNumber($number) {
    $cleaned = preg_replace('/[\s\-\(\)\.]/', '', $number);
    $domestic = preg_match('/^0[2567][0-9]{8}$/', $cleaned);
    $international = preg_match('/^\+212[2567][0-9]{8}$/', $cleaned);
    return $domestic || $international;
}

What are Morocco's mobile phone prefixes?

Morocco mobile numbers start with 06 or 07 prefixes. These prefixes are nationwide (not region-specific) and apply to all three major carriers: Maroc Telecom, Orange Morocco, and INWI. Format: 0[6-7]XXXXXXXX (10 digits domestic) or +212 [6-7]XXXXXXXX (9 digits international). Mobile prefixes 06 and 07 help identify mobile numbers versus landlines (02/05 prefixes).

What are the emergency numbers in Morocco?

Morocco's emergency numbers are: 190 for Police (or 112 from mobile phones), 177 for Royal Gendarmerie, and 150 for Ambulance/Fire. Note that 911 does not work in Morocco. All emergency numbers are toll-free and work without a SIM card or credit balance.

Is VoIP allowed in Morocco?

Yes, VoIP is legal in Morocco since February 2022. The ANRT lifted the ban that was in place from January 2016. WhatsApp calls, Skype, and other Voice over Internet Protocol applications are now legally permitted. Ensure your VoIP service complies with ANRT regulations and licensing requirements.

How long does number portability take in Morocco?

Number portability in Morocco takes one business day (24 hours). The ANRT implemented this faster timeline in April 2024, reducing it from the previous two-day requirement. Porting is free for all subscribers and covers all operators (Maroc Telecom, Inwi, Orange) and number types.

What are Morocco's area codes for landlines?

Morocco's landlines use 05 for urban areas and 02 for rural/southern areas. Unlike mobile prefixes, area codes can vary within cities—for example, Casablanca has 10 different prefixes across operators. Morocco uses a closed numbering plan, so always dial the complete 10-digit number, even for local calls.

Conclusion

You now have a detailed understanding of Morocco's telephone numbering system. Follow these guidelines and best practices to ensure your applications handle Moroccan phone numbers accurately and efficiently. Consult the ANRT Developer Portal for the latest updates and technical specifications.

Quick Reference Checklist:

  • ✓ Validate numbers using regex patterns for domestic and international formats
  • ✓ Store numbers in international format (+212) for consistency
  • ✓ Handle format conversion between domestic and international
  • ✓ Support all valid prefixes: 02, 05, 06, 07, 08
  • ✓ Implement proper error handling with descriptive messages
  • ✓ Test with edge cases (special services, emergency numbers)
  • ✓ Account for number portability in carrier detection logic
  • ✓ Verify VoIP licensing requirements for commercial use
  • ✓ Keep emergency numbers (190, 177, 150, 112) unblocked

Additional Resources: