Legal notice: Generated NIFs are mathematically valid but are not assigned to any real person or company in the Portuguese tax authority (AT) database. For software testing and QA only. Using them to misrepresent identity is illegal.
What is a Portuguese NIF?
The NIF (Número de Identificação Fiscal) is Portugal's 9-digit tax identification number, equivalent to a Tax ID or TIN in other countries. It is issued by the Portuguese Tax and Customs Authority (Autoridade Tributária e Aduaneira — AT) and is required for all economic activity in Portugal, from opening a bank account and signing a rental contract to filing a tax return or registering a company.
NIF First-Digit Reference Table
The first digit of a NIF encodes the entity type. Here is the complete reference:
| First digit(s) | Entity type | Issued by |
|---|---|---|
| 1, 2, 3 | Portuguese individual taxpayer | AT (Tax Authority) |
| 45 | EU citizen without Portuguese residency | AT |
| 5 | Corporation / company (NIPC) | IRN / AT |
| 6 | Public body or state entity | AT |
| 7 | Non-resident (irregular regime) | AT |
| 8 | Non-resident (flat-rate regime) | AT |
| 9 | Collective entity, non-profit, or association | AT |
How the Modulo 11 Algorithm Works
The NIF is validated using a weighted checksum called Modulo 11. Here is the step-by-step process our generator uses:
Generate the first 8 digits, with the first digit set to the entity type (e.g. 1 for an individual).
Multiply each digit by a descending weight: digit 1 × 9, digit 2 × 8, digit 3 × 7 … digit 8 × 2.
Sum all the products to get a total T.
Calculate the remainder: R = T mod 11.
If R is 0 or 1, the check digit (9th digit) is 0. Otherwise, the check digit is 11 − R. (If the result is 10, use 0.)
Why Use Generated NIFs in Development?
Using real NIF numbers in staging or development environments is a GDPR violation under Article 5(1)(b) (purpose limitation) and Article 25 (data protection by design). Generated NIFs pass all format and check-digit validations, making them indistinguishable from real NIFs to any validation library — allowing you to test form logic, billing systems, tax ID fields, and fiscal documents safely.