Developers
Nigerian phone number formats for developers
A Nigerian mobile number in E.164 format is +234 followed by ten digits, where the local leading 0 is dropped: 08012345678 becomes +2348012345678. Storing numbers in E.164 and normalising at the point of entry removes most SMS delivery failures caused by formatting.
What is the correct format for a Nigerian phone number?
In international E.164 form it is +234 followed by ten digits: +2348012345678. The local form of the same number is 08012345678 - the same ten digits with a national trunk prefix 0 in front of them. Converting between the two is simply removing or adding that leading 0.
| Form | Example | Use it for |
|---|---|---|
| E.164 | +2348012345678 | Storage, APIs, deduplication - the only form Sendozi accepts |
| International without plus | 2348012345678 | Some gateways and CSV exports; accepted by Sendozi |
| Local national | 08012345678 | What Nigerian users type. Normalise before use. |
| Spaced local | 0801 234 5678 | Display and print. Strip the spaces before validating. |
| Dialling-prefix international | 002348012345678 | Legacy exports. Replace the leading 00 with +. |
How the ten digits are structured
A Nigerian mobile number is a three-digit network prefix followed by seven subscriber digits. The prefix always begins 70, 71, 80, 81, 90 or 91 - which is why a validator can reject a great deal of rubbish cheaply, before any network is involved.
^\+?234[789][01]\d{8}$- 234 - the Nigerian country code.
- [789][01] - the first two digits of the mobile prefix: 70, 71, 80, 81, 90 or 91.
- Eight further digits, completing the ten-digit national number.
- The leading + is optional on input; Sendozi normalises it back on.
Normalising a number
- 1
Strip everything that is not a digit or a leading plus
Spaces, hyphens, brackets and non-breaking spaces pasted from spreadsheets.
- 2
Replace a leading 00 with +
The international dialling prefix in E.164 form is +.
- 3
If it starts with 0 and is 11 digits, replace the 0 with +234
This is the common Nigerian local form.
- 4
If it starts with 234, prefix +
Already international, just missing the plus.
- 5
If it is 10 digits starting 7, 8 or 9, prefix +234
A number entered without the trunk 0, which happens on forms that show a +234 prefix beside the field.
- 6
Validate the result against the pattern
Reject anything that does not match, rather than sending it and paying for the failure.
const NIGERIAN_MOBILE = /^\+234[789][01]\d{8}$/;
export function normaliseNigerianMobile(input: string): string | null {
let value = input.trim().replace(/[\s()\-.]/g, "");
if (value.startsWith("00")) value = `+${value.slice(2)}`;
if (/^0\d{10}$/.test(value)) value = `+234${value.slice(1)}`;
else if (/^234\d{10}$/.test(value)) value = `+${value}`;
else if (/^[789][01]\d{8}$/.test(value)) value = `+234${value}`;
return NIGERIAN_MOBILE.test(value) ? value : null;
}import re
NIGERIAN_MOBILE = re.compile(r"^\+234[789][01]\d{8}$")
_STRIP = re.compile(r"[\s()\-.]")
def normalise_nigerian_mobile(raw: str) -> str | None:
value = _STRIP.sub("", raw.strip())
if value.startswith("00"):
value = "+" + value[2:]
if re.fullmatch(r"0\d{10}", value):
value = "+234" + value[1:]
elif re.fullmatch(r"234\d{10}", value):
value = "+" + value
elif re.fullmatch(r"[789][01]\d{8}", value):
value = "+234" + value
return value if NIGERIAN_MOBILE.fullmatch(value) else None<?php
function normaliseNigerianMobile(string $raw): ?string
{
$value = preg_replace('/[\s()\-.]/', '', trim($raw));
if (str_starts_with($value, '00')) {
$value = '+' . substr($value, 2);
}
if (preg_match('/^0\d{10}$/', $value)) {
$value = '+234' . substr($value, 1);
} elseif (preg_match('/^234\d{10}$/', $value)) {
$value = '+' . $value;
} elseif (preg_match('/^[789][01]\d{8}$/', $value)) {
$value = '+234' . $value;
}
return preg_match('/^\+234[789][01]\d{8}$/', $value) ? $value : null;
}-- Normalise an existing column in place, then keep the constraint.
update contacts
set phone = '+234' || right(regexp_replace(phone, '[^0-9]', '', 'g'), 10)
where phone !~ '^\+234[789][01][0-9]{8}$'
and right(regexp_replace(phone, '[^0-9]', '', 'g'), 10) ~ '^[789][01][0-9]{8}$';
alter table contacts
add constraint contacts_phone_e164
check (phone ~ '^\+234[789][01][0-9]{8}$');Validation traps that cost money
| Trap | What goes wrong | Fix |
|---|---|---|
| Storing numbers as integers | The leading 0 disappears and 08012345678 becomes 8012345678 | Store as text, in E.164 |
| Excel exports | Long numbers become 8.01235E+10, and leading zeroes are eaten | Export as text, or import the raw CSV |
| Deduplicating before normalising | +2348012345678 and 08012345678 count as two contacts | Normalise first, then deduplicate on the E.164 value |
| Trusting a length check alone | 11 digits passes for numbers that are not mobiles at all | Check the prefix pattern too |
| Accepting whatever the user typed | Invalid recipients are rejected at send time, after the campaign has started | Validate at the form, and again at import |
| Assuming a prefix means a network | Ported numbers are misrouted or mis-segmented | Do not segment by prefix |
One more habit is worth adopting: normalise on the way in, not on the way out. If every entry point - signup form, CSV import, admin panel, partner API - writes E.164, then everything downstream can assume it. Normalising at send time means every consumer of the data has to remember to do it.
When to reach for a library
For a Nigeria-only product, the regular expression above is sufficient and has no dependency cost. If you also handle other countries, use Google's libphonenumber (or a port of it) rather than accumulating per-country regexes - it tracks numbering plan changes, which a hand-written pattern will not.
Frequently asked questions
- What is the country code for Nigeria?
- +234. In E.164 a Nigerian mobile number is +234 followed by ten digits, with the local leading 0 removed.
- How do I convert 08012345678 to international format?
- Drop the leading 0 and prefix +234, giving +2348012345678. Nothing else about the number changes.
- Which prefixes are valid Nigerian mobile numbers?
- Mobile numbers begin 70, 71, 80, 81, 90 or 91 after the country code, followed by eight more digits. The pattern ^\+?234[789][01]\d{8}$ matches all of them.
- Does Sendozi accept numbers in local 0 format?
- No. The SMS API accepts +234 or 234 followed by a valid ten-digit mobile number. A local 0-prefixed number is rejected with invalid_recipient, so normalise before sending.
- Can I tell which network a Nigerian number belongs to from its prefix?
- Not reliably. Number portability means a subscriber keeps their number when they change network, so prefix-based network detection is wrong for ported numbers.
Related reading
Developers
OTP SMS in Nigeria: designing verification that works
How to deliver one-time passwords by SMS in Nigeria: transactional routing, expiry and retry discipline, idempotency, rate limiting, message wording and a working API integration.
SMS
Bulk SMS in Nigeria: the complete guide
How bulk SMS works in Nigeria: sender IDs, transactional and promotional routes, the DND register, page-based pricing, delivery reports and consent. Written for teams sending their first campaign.
SMS
SMS character limits, Unicode and message length
Why an SMS holds 160 characters in GSM-7 but only 70 in Unicode, what happens when a message is concatenated, how emoji and Nigerian-language text change the count, and how Sendozi bills pages.