Australian Tax File Number Generator (TFN)

GuidesMisc.RandomUseful

Updated Tool Available

There’s now an easier to access version of this tool available at the following link: Australian Tax File Number (TFN) Generator

Along with a few other widgets that have been added more recently:

Original Post

Sample Australian Tax File Numbers/Test Australian Tax File Numbers:

865414088459599230125486619
656077298796801997754601340
243494429953615761551953801
946489031996506823615315318
412042562907974668565051603

I came across an old VB Script used to generate random TFNs for testing. I’ve just done up a quick JavaScript bookmarklet to replace it. Just drag the button on the page below to your bookmarks bar and you’ll be able to generate random TFNs.

Get the generator: TFN Generator

A bookmarklet to generate random TFNs

A bookmarklet to generate random TFNs

For info on how it all works, checkout the Wikipedia page: Australian Tax File Number

UPDATE:
If you’re using IE, right click on the link and press add to favourites. Once you’ve added it, click the link in your favourites sidebar. The generator will appear in the top right hand corner of the page.

Let me know if you have any trouble. If you’d like to a custom or corporate copy please contact me.

21 comments

Comments from the original blog are preserved here. New comments are closed.

  1. victoria

    how would i calculate the algorithm myself?

  2. Chris Owens
    In reply to victoria

    Hey Victoria,

    It's actually a pretty basic one surprisingly, you can grab it all of of the wikipedia page or just copy the code I've used for the generator here.

    Wikipedia: http://en.wikipedia.org/wiki/Tax_File_Number

    Let me know if you have any trouble.

    Cheers,
    Chris

  3. Matt

    Just wanted to post a quick thanks - this is amazingly useful.

  4. Chris Owens
    In reply to Matt

    No worries Matt, thanks for the feedback!

  5. Anna

    this is great, do you have a similar generator for NZ IRD numbers?

  6. Chris Owens
    In reply to Anna

    Hey Anna,

    Not currently, but I might have a look if I get a bit of time. The formula seems pretty similar:

    http://www.ird.govt.nz/resources/b/9/b9369180451ef8e19355bb7747109566/rwt-nrwt-spec-2011-v1.pdf (original file unavailable)

    A modulus 11 digit check of currently-held employee IRD numbers should be done to ensure that
    all numbers are valid.
    If an invalid number is found, it should be changed to 000000000 with a tax code of ND (no
    notification).
    The employee should then be asked to provide the correct IRD number. Employees can verify
    their IRD number from their IR card or any correspondence that the employee has received from
    us.
    The IRD number format used by Inland Revenue is a nine digit number, where the IRD number
    has only eight digits a leading 0 (zero) will be used.
    Check digit validation
    The following steps are to be performed:
    • Valid range >10,000,000 & <150,000,000 (This will ensure invalid numbers that will not
    be issued for another 10 years cannot be used in error)
    • To each of the base number’s nine digits a weight factor is assigned. From left to right
    these are: 3, 2, 7, 6, 5, 4, 3, 2.
    • Where the base number is eight digits remember there is a leading zero.
    • Sum together the products of the weight factors and their associated digits.
    • Divide the sum by 11. If the remainder is 0 then the check digit is 0.
    • If the remainder is not 0 then subtract this number from 11, giving the check digit (0 - 9
    are valid).
    • If the resulting check digit is 10, use a secondary set of weight factors and apply steps 2
    and 3 to the same input base number. From left to right the factors for an eight digit
    base number are: 7, 4, 3, 2, 5, 2, 7, 6.
    • Remember there is a leading zero for a eight digit base number. If the new check digit is
    again 10 then the IRD number is invalid (0 - 9 is valid).
    • Compare the calculated check digit with the check digit on the IRD number. If they
    match then the IRD number is valid.
    Example 1
    IR number 49091850. The base number is 49091850 and the supplied check digit is 0. The
    number is greater than 10,000,000. Using the weightings above:
    (0*3) + 4*2) + (9*7) + (0*6) + (9*5) + (1*4) + (8*3) + (5*2) = 154.
    154 / 11 = 14 remainder 0 (i.e. mod(154,11) = 0)
    The remainder (0) = check digit (0), so no further calculation is necessary
    Example 2
    IR number 35901981. The base number is 3590198 and the supplied check digit is 1. The number
    is greater than 10,000,000. Using the weightings above:
    (0*3) + 3*2) + (5*7) + (9*6) + (0*5) + (1*4) + (9*3) + (8*2) = 142.
    142 / 11 = 12 remainder 10 (i.e. mod(142,11) = 10)
    11 – 10 = 1 which matches the check digit.
    The number is valid.
    Example 3
    IR number 49098576. The base number is 4909857 and the supplied check digit is 6. The number
    is greater than 10,000,000. Using the weightings above:
    (0*3) + (4*2) + (9*7) + (0*6) + (9*5) + (8*4) + (5*3) + (7*2) = 177 .
    177 / 11 = 16 remainder 1 (i.e. mod(177,11) = 1)
    IR Electronic Filing
    12
    11 – 1 = 10 so perform the secondary calculation.
    (0*7) + (4*4) + (9*3) + (0*2) + (9*5) + (8*2) + (5*7) + (7*6) = 181
    181 / 11 = 16 remainder 5 (i.e. mod(181,11) = 5)
    11 – 5 = 6 which matches the check digit.
    The number is valid.
    Example 4 (9 digit IRD number)
    IR number 136410132. The base number is 13641013 and the supplied check digit is 2. The
    number is greater than 10,000,000. Using the weightings above:
    (1*3) + (3*2) + (6*7) + (4*6) + (1*5) + (0*4) + (1*3) + (3*2) = 89 .
    89 / 11 = 8 remainder 1 (i.e. mod(89,11) = 1)
    11 – 1 = 10 so perform the secondary calculation.
    (1*7) + (3*4) + (6*3) + (4*2) + (1*5) + (0*2) + (1*7) + (3*6) = 75
    75 / 11 = 6 remainder 9 (i.e. mod(75,11) = 9)
    11 – 9 = 2 which matches the check digit.
    The number is valid.
    Example 5 (9 digit IRD number)
    IR number 136410133. The base number is 13641013 and the supplied check digit is 3. The
    number is greater than 10,000,000. Using the weightings above:
    (1*3) + (3*2) + (6*7) + (4*6) + (1*5) + (0*4) + (1*3) + (3*2) = 89 .
    89 / 11 = 8 remainder 1 (i.e. mod(89,11) = 1)
    11 – 1 = 10 so perform the secondary calculation.
    (1*7) + (3*4) + (6*3) + (4*2) + (1*5) + (0*2) + (1*7) + (3*6) = 75
    75 / 11 = 6 remainder 9 (i.e. mod(75,11) = 9)
    11 – 9 = 2 which does not match the check digit (3).
    The number is invalid.
    Example 6
    IR number 9125568. The number is less than 10,000,000 so fails the first validation.
    The number is invalid.

  7. Chris Owens
    In reply to Anna

    Hey @anna,

    Just to let you know I've added a NZ IRD number generator and validator to another site:
    - Validator: https://testerwidgets.com/widgets/6/new-zealand-ird-number-validator
    - Generator: https://testerwidgets.com/widgets/5/new-zealand-ird-number-generator

    Please let me know if you hit any issues!

  8. Kevin

    Came across your TFN generator today. Thanks for sharing it, it's great!

  9. Chris Owens
    In reply to Kevin

    No worries Kevin, thanks for the feedback!

  10. Hi Chris, the generator is really useful for development team working in finance or insurance industry. Have you consider to open source the implementation somewhere like github so that people could utilize it better?

    Anyway, nice job and thanks for sharing!

  11. M

    Hi Chris

    This is really helpful for testers and BA's too.

    Its superb.

  12. Chris Owens
    In reply to M

    Thanks for the feedback M, appreciate it!

  13. Kim

    Chris. You're wonderful for sharing this. Thank you so much. Extremely useful especially where you have applications that validate TFNs. Awesome work.

  14. Chris Owens
    In reply to Kim

    Thanks Kim! Glad it came in handy.

  15. Chris Owens

    Sorry this stopped working for a while - had moved to a new host and didn't realise that they'd stripped all of the code. It's back up now so please let me know if you have any issues.

    Cheers,
    Chris

  16. Unable to parse parameter: azuredeploy.parameters.dev.json &#8211; Azure Bicep | What I Broke – JavaScript, C#, AWS and General Development

    […] been trying out Bicep as a replacement for ARM templates for a mini side project to replace the TFN generator people are currently using on this […]

  17. Walter

    Hi Chris, any chance on an IRD Generator?

  18. Chris Owens
    In reply to Walter

    Hi Walter,

    I'm a little tied up for the next few weeks sorry mate. If I get a few hours spare after that I'll see if I can put something together for you!

    Cheers,
    Chris

  19. Chris Owens
    In reply to Walter

    Hey @Walter,

    Just a heads up that I've added a NZ IRD number generator and validator to another site:
    - Validator: https://testerwidgets.com/widgets/6/new-zealand-ird-number-validator
    - Generator: https://testerwidgets.com/widgets/5/new-zealand-ird-number-generator

    Let me know if there are any issues!

  20. adelaidetech

    One thing that seems to be missing when searching google for TFN generators is something that generates invalid numbers. For demo systems and some testing it would be good to be able to generate TFNs that look OK but fail the validation (so you know they aren't real by accident).

  21. Chris Owens
    In reply to adelaidetech

    Hey @adelaidetech,

    I've moved this out to a small standalone site and have included a TFN validator if that helps to address this? https://testerwidgets.com/widgets/4/australian-company-number-validator

    Cheers,
    Chris