Kenya has one of East Africa’s most dynamic telecoms markets. With Safaricom’s M-Pesa platform processing more than half the country’s GDP in digital transactions, having a correctly formatted Kenyan phone number is not just a UX nicety — it is a prerequisite for payments, OTP delivery, and onboarding flows. This validator checks any Kenyan number format against the real E.164 structure and the Communications Authority of Kenya’s published operator prefix allocations, entirely inside your browser.
How it works
Kenya’s national telephone numbering plan assigns a 9-digit national significant number to each subscriber. The country code is +254. Mobile numbers always begin with 7, followed by an operator-specific digit, making the local form 07XX XXX XXX (10 digits with the leading zero, or 9 without it). Fixed-line numbers use two-digit area codes — Nairobi is 20, Mombasa 40 or 41, Nakuru 50, and so on.
The validator accepts input in any of these forms and normalises it to a canonical 9-digit national number by stripping the country code prefix (254) or local leading zero as appropriate. Once normalised, it performs two checks:
-
Length check — the national number must be exactly 9 digits. Mobile numbers are always
7XXXXXXXX; fixed-line numbers follow a two-digit area-code plus a 7-digit subscriber number structure (also 9 digits total without the leading zero). -
Prefix check — the first two digits of the national number are matched against the known operator allocation table. Safaricom holds 70, 71, 72, and 79; Airtel Kenya holds 73, 74, 75, and 78; Telkom Kenya holds 77; and Equitel (the banking operator run by Equity Bank) holds 76. Fixed-line area codes are checked against the Communications Authority’s geographic table.
If both checks pass, the tool returns the formatted E.164 number (+254 7XX XXX XXX),
the local format (07XX XXX XXX), the identified operator or region, and copy buttons
for both formats.
Worked example
Suppose you receive the number 0722 123 456 in a web form. Here is what the validator does step by step:
- Strip the leading zero:
722123456— 9 digits, passes the length check. - Two-digit prefix:
72— matches Safaricom in the allocation table. - Build E.164:
+254plus722123456=+254722123456, displayed as+254 722 123 456. - Build local:
0plus722123456=0722123456, displayed as0722 123 456. - Result: Valid Kenyan Mobile Number — Safaricom.
Now compare with 0800 720 122 (a Safaricom toll-free number). After stripping the
leading zero you get 800720122, 9 digits. The prefix 80 is not in the mobile or
fixed-line allocation table, so the validator returns unknown prefix — correct,
because toll-free ranges use a separate numbering plan not covered here.
| Input format | Normalised | Result |
|---|---|---|
+254 712 345 678 | 712345678 | Valid — Safaricom mobile |
0733 000 000 | 733000000 | Valid — Airtel Kenya mobile |
020 222 2222 | 202222222 | Valid — Telkom fixed, Nairobi |
0776 543 210 | 776543210 | Valid — Telkom Kenya mobile |
+255 712 345 678 | N/A | Wrong country code (Tanzania) |
0712 34 56 | 71234 56 | Wrong length (7 digits) |
Every calculation runs locally — nothing is ever uploaded.