Skip to content
GitHub

Spec 0.14.0

Madagascar phone numbers: rules and sources

Reads, checks and formats Malagasy phone numbers, mobile and fixed (country code +261).

  1. A number has 9 significant digits after +261: a 2-digit operator code, then 7 digits.

  2. Accepted spellings of the same number 34 12 345 67: 034 12 345 67, +261 34 12 345 67, 00261 34 12 345 67, 261 34 12 345 67, 34 12 345 67.

    • 0 is the national trunk prefix; 00 is the international prefix.
    • Spaces (including non-breaking and other Unicode spaces), -, ., ( and ) are ignored. A + is allowed only as the first character.
    • Any other character (letters, _, full-width digits) is INVALID_FORMAT.
    • The 9 significant digits never start with 0, so 034 12 345 6 (one digit short) is INVALID_FORMAT, not a 9-digit number with operator 03.
    • Input longer than 32 characters is INVALID_FORMAT, so parsers never scan unbounded text.
  3. Operator codes 30–39 are mobile. Assigned codes:

    Code Operator Assigned
    32 Orange Madagascar 2013 plan
    33 Airtel Madagascar 2013 plan
    34 Yas Madagascar (formerly Telma) 2013 plan
    35 Airtel Madagascar 22 Jun 2026
    36 Yas Madagascar (formerly Telma) 2026
    37 Orange Madagascar 21 Oct 2022
    38 Yas Madagascar (formerly Telma) 21 Oct 2022
    39 Blueline (MVNO) 21 Aug 2013

    Codes 20–29 are fixed lines (2013 plan): 20 is the Yas (Telecom Malagasy) fixed network, 22 is Gulfsat Madagascar VSAT. After 20 comes a zone digit (2 and 4 Antananarivo, 5 Toamasina, 6 Mahajanga, 7 Fianarantsoa, 8 Antsiranana, 9 Toliara), then 6 subscriber digits. A geographic number gives its town when the plan lists it (020 53 … → Toamasina); otherwise its area is null. A well-formed number with any other code, or a 20 number with an unlisted zone, is UNKNOWN_OPERATOR.

  4. Formats (formatPhone):

    Format Output for 0341234567
    e164 +261341234567
    international +261 34 12 345 67
    national 034 12 345 67

    Any other format name is INVALID_TYPE.

  5. Non-string input is INVALID_TYPE for parsePhone and formatPhone; isValidPhone never throws and returns false.

e164: '+261341234567'
nationalNumber: '341234567'
operator: yas
type: mobile # or fixed
area: null # for a geographic fixed number: { name: Toamasina, province: Toamasina }
  • Grouping for 39. The 2013 Blueline communication writes +261 39 XXX XXXX; the 2013 plan and the 2022 communication write +261 3X XX XXX XX. The data uses the 2-2-3-2 grouping for every operator so one number always looks the same.
  • Is 39 still active? The ITU record does not withdraw 39. Until an official withdrawal is published, the data keeps it.
  • 37 on the ARTEC page. The ARTEC web page does not list 37; the ITU communication of 21 Oct 2022 assigns it to Orange Madagascar. The data follows the ITU communication, which is the later and formal notice.