Skip to main content

Portuguese Citizen Card Validator

Validate 12-character Portuguese Cartão de Cidadão numbers in real time.

Portuguese Cartão de Cidadão Validation

Validates the 12-character format (NNNNNNNN C XX Y) using the official alphanumeric Luhn mod 10 checksum algorithm.

Ensures compliance for Portuguese user onboarding and identity verification software.

Anatomy & Structure of Portuguese Citizen Card

The Citizen Card document number comprises 12 characters across 4 functional blocks:

PositionFieldLengthMeaning & RuleExample
1 to 8Civil ID (NIC)8 digitsNational Civil ID number, zero-padded if necessary12345678
9NIC Check Digit1 digitMathematical checksum of the Civil ID component9
10 & 11Version Code2 charsAlphanumeric document physical issuance version codeZZ
12Overall Check Digit1 charGlobal document checksum computed via base-36 Luhn algorithm4

Citizen Card Validation Algorithm (Luhn in Base 36)

The official IRN/AMA algorithm evaluates all 12 characters right-to-left in base 36:

sum(double_or_direct(Base36(char_i))) % 10 == 0
  1. 1. Map each character to base-36 value: digits 0-9 retain value; letters A-Z map to 10-35 (ASCII - 55).
  2. 2. Processing right-to-left (i=0 to 11), double values at odd positions (1, 3, 5, 7, 9, 11).
  3. 3. If doubled value exceeds 9, subtract 9 from it.
  4. 4. Keep direct values at even positions (0, 2, 4, 6, 8, 10).
  5. 5. Sum all components: document is valid if the grand total is evenly divisible by 10 (sum % 10 == 0).

Frequently Asked Questions