NZBN Validator

Check whether a New Zealand Business Number is valid

Loading...

GS1 modulus 10, not Luhn

An NZBN validator is a GS1 Global Location Number validator, because that is what an NZBN is. Working from the right, multiply the twelve digits before the check digit alternately by 3 and 1, add the products, and the check digit is the amount needed to reach the next multiple of ten.

Several widely copied descriptions call this the Luhn algorithm. They are wrong, and the distinction is worth knowing if you are writing your own implementation: Luhn doubles alternate digits and folds anything above nine back into a single digit, which GS1 does not do. The two agree on enough inputs that a careless test will pass, and disagree on enough that production will not.

The 9429 prefix

New Zealand numbers are allocated under the GS1 company prefix 9429. That is an allocation convention rather than a rule in the standard, so a thirteen digit number with a correct check digit but a different prefix gets a warning here rather than a rejection. It is most likely a valid location number issued somewhere else in the world, and calling it invalid would be overstating what the arithmetic proves.

What the register can tell you and this cannot

Whether a business exists, what it is called, who its directors are and whether it is still trading are all published, free, on the official NZBN register. A check digit answers none of them. Use this tool to catch data entry errors on the way in, and the register for anything that matters.

Working with NZBNs in code

Store all thirteen digits as text, validate on entry, and strip spaces before checking, since the register displays numbers grouped. If you need numbers that pass without belonging to anybody, the NZBN generator produces them in batches. The check runs in your browser and nothing you type leaves the page.

Frequently Asked Questions

What algorithm does an NZBN use?

The GS1 modulus 10, because an NZBN is a GS1 Global Location Number. Working from the right of the first twelve digits, multiply alternately by 3 and 1, add the products, and the check digit is the amount needed to reach the next multiple of ten.

Is the NZBN check digit the Luhn algorithm?

No, although plenty of sources say so. Luhn doubles alternate digits and folds any result above nine back into a single digit; GS1 multiplies by three and never folds. The two produce the same answer often enough that a small test suite will not notice, and different answers often enough to matter in production.

Do all NZBNs start with 9429?

New Zealand allocates NZBNs from the GS1 company prefix 9429, so in practice yes. It is an allocation convention rather than a rule in the standard, so a thirteen digit number with a valid check digit and a different prefix is flagged here as a warning: it is probably a location number issued in another country.

Where do I look up the business behind an NZBN?

The official NZBN register, which is free and public. It carries the trading name, entity type, addresses and directors. A check digit tells you only that the number was typed correctly, never whose it is.