Every South African citizen or resident is issued with a 13 digit ID number in the format YYMMDD GSSS CAZ, where:

- YYMMDD is the date of birth. Note this means that a person born on 1 Jan 1900 and 1 Jan 2000 will have the same first 6 digits (000101);
- G indicates gender, where females are assigned sequential numbers in the range 0-4 and males from 5-9;
- SSS is a sequence number of the birth registered on that birth date;
- C indicates citizenship, where 0 is a SA citizen, and 1 is a permanent resident (only citizens can vote);
- A is usually an 8 (could also be a 9 according to DHA
^{[1]}). Prior to 1986^{[2]}this number was used to indicate the holder’s race; - Z is a checksum digit.

The checksum digit (Z) is calculated using the Luhn algorithm :

A = The sum of the odd-positioned digits (positions 1,3,5,7,9,11 and excluding 13/Z)

B = The concatenation of the even-positioned digits (positions 2,4,6,8,10,12)

C = The sum of the digits in the result of B x 2

D = A + C

Z = 10 – (D mod 10) ^{[3]}

Thus, for a theoretical ID number of a South African Resident female born on 22 November 2000, with ID number 001122 3344 182, the calculation of the check bit in red is as follows:

`A = 0 + 1 + 2 + 3 + 4 + 1 = 11`

B = 012348

C = 012348 x 2 = 24696

C = 2 + 4 + 6 + 9 + 6 = 27

D = 11 + 27 = 38

Z = 10 - (38 % 10) = 10 - 8 = 2

Note also, that the fictitious ID number 001122 3344 182 is valid for a birth date of 22 November 1900 as well as 22 November 2000.

An excellent spreadsheet by Robert MacLean which implements this check for your reuse is available from here.

And that’s that.

1. Note in the new ID books a note on this bit says, “Usually 8. If yours is a 9 please ensure that you have a letter confirming authentication of your ID documents from Home Affairs.”

2. Identification Act No 72 of 1986 repealed the 1952 Blacks (Abolition of Passes and Co-ordination of Documents) Act and large portions of the 1950 Population Registration Act. Identity numbers would no longer reflect a person’s race group in terms of the 1950 Population Registration Act or any other law. Influx control regulations were lifted and passes were to be replaced by a uniform identity document for all population groups.

3. The mod or Modulo operator as used here effectively returns the rightmost digit of the number on the left. If the result of the mod operation is a 0, then Z turns out to be 10 – 0 = 10. In this instance the the resulting check bit is 0.

NOTE: To validate South African ID number using Javascript, try this.