RFC (Registro Federal de Contribuyentes, Mexican tax number).

This number is used to identify individuals and companies for tax purposes.

The company number is 12 digits where the first 3 letters or digits are derived from the name of the company, the following 6 contain the date of incorporation, followed by 3 check digits.

Personal numbers consist of 13 digits where the first 4 characters from the person’s name, followed by their birth date and 3 check digits.

The first two check digits are calculated based on the person’s or company’s full name. The last check digit is calculated over all the preceding digits in the number. However, it seems a lot of numbers (estimated at around 1.5% of all numbers) are in use with invalid check digits so this test is disabled by default.

More information:

An online validation service is available at:

>>> validate('GODE 561231 GR8')  # personal number
>>> validate('MAB-930714-8T4')  # company number
>>> validate('COMG-600703')  # personal number without serial
>>> validate('VACE-460910-SX6')
>>> validate('VACE-460910-SX6', validate_check_digits=True)
Traceback (most recent call last):
InvalidChecksum: ...
>>> format('GODE561231GR8')
'GODE 561231 GR8'

Calculate the check digit. The number passed should not have the check digit included.

Convert the number to the minimal representation. This strips surrounding whitespace and separation dash., separator=' ')

Reformat the number to the standard presentation format., validate_check_digits=False)

Check if the number provided is a valid RFC., validate_check_digits=False)

Check if the number is a valid RFC.