Validate Portuguese VAT Numbers (NIF) in Node.js
Originally published at vatnode.dev . The version on vatnode.dev is the canonical source — refer to it for the latest content. Portugal issues one 9-digit body under the PT prefix, and that body is also the holder’s national NIF – there’s no separate VAT-specific sequence to keep in sync. The part worth getting right in code is the mod-11 check digit and, more importantly, what to do when VIES PT…
Portugal issues a 9-digit NIF as its National Tax Identification Number, which is also the holder's VAT number. This NIF has no separate sequence, unlike some other countries. The format of a Portuguese VAT number is a simple PT followed by 9 digits with no separators or letters. The 9th digit serves as a check digit calculated through a mod-11 algorithm. The Portuguese VAT number structure is unique and does not split into separate entity-specific and VAT-specific parts.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.