The NIF (Número de Identificação Fiscal) has 9 digits and the last one is a check digit computed with modulus 11: the first 8 digits are multiplied by 9, 8, 7, 6, 5, 4, 3 and 2, added up, and the remainder of the division by 11 sets the ninth. A remainder of 0 or 1 gives 0, anything else gives 11 minus the remainder. For 123456789 the sum is 156, the remainder is 2 and the digit is 9.
The first digit (or first two) tells who the holder is, according to the Portuguese Tax and Customs Authority (AT) manual: 1, 2 and 3 are individuals (range 3 was announced in 2019), 45 non-resident individuals with withholding tax, 5 legal entities, 6 public administration, 70 and 74 undivided estates, 71 non-resident entities, 72 funds, 77 and 78 ex officio assignments, 90 and 91 condominiums and irregular companies, 98 non-residents and 99 civil companies. Prefix 8 (sole trader) is obsolete.
The NISS (Número de Identificação da Segurança Social) has 11 digits. Public validators multiply the first 10 by 29, 23, 19, 17, 13, 11, 7, 5, 3 and 2 and use 9 minus the sum's remainder by 10 as the last digit. I did not find that calculation in an official text, so treat it as a well-established convention. The NIB has 21 digits (bank, branch, account and 2 check digits) and follows ISO 7064 mod 97-10, per Banco de Portugal: read as one number it leaves remainder 1 when divided by 97. The IBAN is PT50 plus the NIB.
Passing the check only says the number is well formed. To find out whether a VAT number is active, use the European Commission's VIES service.
How to use
Paste, read the type, fix or generate.
In Validate mode, paste a NIF, NISS, NIB or IBAN. The type is detected by length, and you can force it under Number type.
Read the verdict, the taxpayer type (for a NIF) or the NIB parts. If the check is wrong, the tool shows the number with the right digit.
In Generate mode, pick NIF, NISS, NIB or IBAN, adjust the options and copy or export the batch as TXT, CSV or JSON.
Embed
Use this tool on your site
Paste the code into your HTML and the tool shows up on your page, without J-Kit's navigation and ads. It still runs in the browser of whoever visits your site.
<iframesrc="https://jkit.tools/embed/en-US/portugal-nif-validator"width="100%"height="600"style="border:0"loading="lazy"referrerpolicy="no-referrer-when-downgrade"title="Portugal NIF, NISS and NIB Validator and Generator"></iframe><p style="font-size:12px;margin:6px 0 0">Tool by <a href="https://jkit.tools/en">J-Kit</a></p>
References
Sources and references for this tool
These references help contextualize formulas, standards, APIs and limitations used on this page. They do not replace professional validation when a result has legal, financial, medical or operational impact.
Each of the first 8 digits is multiplied by the weights 9, 8, 7, 6, 5, 4, 3, 2 and the products are added. The remainder of the division by 11 decides the ninth digit: 0 or 1 gives 0, and any other remainder r gives 11 minus r. For 204716624 the sum is 139, the remainder is 7 and the digit is 4.