Validating the Australian Tax File Number

Validating Australian Tax File Numbers

Tax file numbers are identifiers issued by the Australian Tax Office to individuals or organisations for tax purposes. Modern TFNs (those issued under the Extend TFN System that took effect from 1 Jan 1989) have 9 digits, consisting of an 8-digit identifer followed by a 1-digit check digit.

The validation algorithm is uses a weighted sum of digits, with weights as follows:

Position123456789
Weight1437586910

A TFN passes verification if the weighted sum of all 9 digits is a product of 11.

Example

TFN Digits876543210
Weightx 1x 4x 3x 7x 5x 8x 6x 9x 10
Sum828183520241290
Validation8 + 28 + 18 + 35 + 20 + 24 + 12 + 9 + 0 = 154 = 14 x 11

PHP Sample Code

//   ValidateTFN
//     Checks TFN for validity using the checksum algorithm.
//
//     Returns: true if the TFN is valid, false otherwise.
//      Source: http://www.clearwater.com.au/code
//      Author: Guy Carpenter
//     License: The author claims no rights to this code.  
//              Use it as you wish.
 
function ValidateTFN($tfn)
{
    $weights = array(1, 4, 3, 7, 5, 8, 6, 9, 10);
 
    // strip anything other than digits
    $tfn = preg_replace("/[^\d]/","",$tfn);
 
    // check length is 9 digits
    if (strlen($tfn)==9) {
        $sum = 0;
        foreach ($weights as $position=>$weight) {
            $digit = $tfn[$position];
            $sum += $weight * $digit;
        }
        return ($sum % 11)==0;
    } 
    return false;
}

References

Reference The checksum algorithm is not publically disseminated by the ATO, but is widely known by software developers.