Morocco CIN Validator

Validate a Moroccan national ID number and decode the issuing bureau.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The Morocco CIN Validator checks a Moroccan Carte Nationale d’Identité (CIN, بطاقة التعريف الوطنية) number against every published structural rule and decodes the letter prefix to the issuing regional bureau. It is the deepest open-source CIN format validator available — covering the full six-step rule chain, the complete 26-letter bureau table, and the two-letter overflow-series system.

How it works

A Moroccan CIN is composed of two parts joined with no separator:

[PREFIX][SERIAL]

The PREFIX is one or two uppercase letters. The first letter identifies the regional bureau of the Direction Générale de la Sûreté Nationale (DGSN) that originally issued the card — for example A for Rabat, B for Casablanca, N for Fès, J for Agadir. When a bureau’s six-digit serial space (000001–999999) is completely exhausted, the DGSN adds a second letter to create an overflow series: BE, BH, BJ, BK, and so on, all still belonging to the Casablanca bureau.

The SERIAL is exactly six decimal digits, zero-padded. It is a sequential counter within the bureau’s series and encodes no date, gender, or other personal information.

The validator runs six checks in order, stopping at the first hard failure:

#CheckWhat it tests
1Character setOnly A-Z and 0-9; no accented letters, punctuation, or spaces
2Total lengthExactly 7 characters (1-letter prefix) or 8 characters (2-letter prefix)
3StructureAll letters come before all digits — no letter appears after the first digit
4Prefix lengthPrefix is exactly 1 or 2 letters
5Serial lengthExactly 6 digits follow the prefix
6Known prefixSoft check — prefix matched against the 26-letter bureau table; unknown prefixes issue a warning but do not fail the number

The sixth check is intentionally non-fatal because the DGSN has introduced many new overflow series since 2010 and any reference table will eventually be incomplete.

Worked example

Take the obviously-fictional number BE123456:

  1. Character setB, E, 1, 2, 3, 4, 5, 6 are all letters or digits. ✓
  2. Total length — 8 characters. ✓
  3. StructureBE (letters) then 123456 (digits), letters-before-digits rule satisfied. ✓
  4. Prefix length — 2 letters. ✓
  5. Serial length — 6 digits. ✓
  6. Known prefixBE is in the reference table → Casablanca (B overflow E), confirmed. ✓

Result: valid format, issuing bureau Casablanca-Settat (overflow series, original B-series exhausted).

For comparison, N012345 is a 7-character CIN: prefix N (Fès bureau, original series), serial 012345.

Formula note

Morocco’s DGSN does not publish a check-digit algorithm for the CIN number. The serial is an opaque sequential counter — the only mathematical property it has is that it must be exactly six decimal digits. This contrasts with systems such as the Brazilian CPF (MOD-11 check digits) or the Chilean RUT (MOD-11 Luhn variant) where the final digit is computable from the preceding ones. For the Moroccan CIN, structural correctness is the only publicly verifiable property.

FAQ

See the questions below for details on the format, the bureau-prefix system, and privacy.

Ad placeholder (rectangle)