tunisia-kit 🇹🇳
A type-safe, zero-dependency toolkit for validating and formatting Tunisian data.

Installation
npm install tunisia-kit
yarn add tunisia-kit
Quick Examples
import { isValidCIN, isValidPhone, isValidRIB, isValidIBAN, isValidLandline } from 'tunisia-kit';
isValidCIN('12345678');
isValidPhone('22555111');
isValidLandline('71234567');
isValidRIB('10005000000000000049');
isValidIBAN('TN5910005000000000000049'); Converting RIB to IBAN
import { ribToIBAN, formatIBAN } from 'tunisia-kit';
const iban = ribToIBAN('10005000000000000049');
formatIBAN(iban);
Identifying Bank & Region
import { getBankFromRIB, getRegionFromLandline } from 'tunisia-kit';
getBankFromRIB('10005000000000000049');
getRegionFromLandline('71234567');
import { formatPhone, formatLandline, formatCurrency } from 'tunisia-kit';
formatPhone('22555111');
formatLandline('71234567');
formatCurrency(1250.5); Populating Dropdowns
import { GOVERNORATES, DELEGATIONS, getDelegationsByGovernorate } from 'tunisia-kit';
GOVERNORATES.map(gov => ({
value: gov.id,
label: gov.name_fr,
labelAr: gov.name_ar
}));
getDelegationsByGovernorate(1); API Reference
Validators
| Function |
Description |
isValidCIN(cin) |
Validates 8-digit Tunisian National ID |
isValidPhone(phone) |
Validates mobile number with provider detection |
isValidLandline(phone) |
Validates landline number with region detection |
isValidRIB(rib) |
Validates 20-digit bank account (Modulo 97) |
isValidIBAN(iban) |
Validates 24-character Tunisian IBAN (ISO 7064) |
isValidMatricule(mat) |
Validates Company Tax ID |
isValidPassport(pass) |
Validates passport number |
isValidLicensePlate(plate) |
Validates Tunisian license plate format |
| Function |
Input |
Output |
formatPhone(str) |
22555111 |
22 555 111 |
formatPhoneIntl(str) |
22555111 |
+216 22 555 111 |
formatLandline(str) |
71234567 |
71 234 567 |
formatLandlineIntl(str) |
71234567 |
+216 71 234 567 |
formatIBAN(str) |
TN59... |
TN59 1000 ... |
formatCurrency(num) |
1250.5 |
1 250,500 TND |
formatCIN(str) |
4555666 |
04555666 |
Utilities
| Function |
Description |
ribToIBAN(rib) |
Convert 20-digit RIB to 24-character IBAN |
getBankFromRIB(rib) |
Get bank name from RIB |
getRegionFromLandline(phone) |
Get region info from landline prefix |
getDelegationsByGovernorate(id) |
Get delegations for a governorate |
Static Data
| Export |
Description |
GOVERNORATES |
All 24 governorates (id, name_fr, name_ar) |
DELEGATIONS |
~260 administrative delegations across all 24 governorates |
BANKS |
21 bank codes for RIB identification |
LANDLINE_REGIONS |
8 landline prefixes with region mapping |
Phone Prefixes
Mobile
- Tunisie Telecom: 9x, 4x
- Ooredoo: 2x
- Orange: 5x
Landline
- 71: Grand Tunis
- 72: Northeast (Nabeul, Bizerte)
- 73: Sahel (Sousse, Monastir)
- 74: Sfax
- 75: Southwest (Gafsa, Tozeur)
- 76: Southeast (Gabès, Médenine)
- 77: Center-West (Kasserine)
- 78: Northwest (Béja, Jendouba)
License
MIT © 2026