A Portuguese NIF (Número de Identificação Fiscal) is the 9-digit tax identification number assigned to every taxpayer in Portugal — individuals, companies, public bodies, investment funds, and sole traders all share the same format. It is also the foundation of the NIPC (Número de Identificação de Pessoa Colectiva) used for legal entities. Whether you are building an invoicing system, validating user input on a checkout form, or cross-checking a supplier’s fiscal number, a reliable NIF validator is essential.
This tool implements the official mod-11 check-digit algorithm used by the Autoridade Tributária e Aduaneira (AT). It runs entirely in your browser — the number never leaves your device — and it shows you the full step-by-step calculation so you understand exactly why a NIF passes or fails.
How the mod-11 algorithm works
Every NIF has nine digits. The first eight carry the actual identifier; the ninth is a check digit computed from them. The algorithm is:
weights = 9 8 7 6 5 4 3 2
digits = d1 d2 d3 d4 d5 d6 d7 d8 d9(check)
sum = (d1×9) + (d2×8) + (d3×7) + (d4×6)
+ (d5×5) + (d6×4) + (d7×3) + (d8×2)
remainder = sum mod 11
control = 11 − remainder
if control >= 10 → control = 0
d9 must equal control
The validator displays every intermediate value — the weighted sum, the remainder, and the expected versus actual check digit — so a single mistyped digit is easy to pinpoint.
Entity-type prefix table
| Prefix | Taxpayer class |
|---|---|
| 1, 2, 3 | Individual person (pessoa singular) |
| 45 | Non-resident individual |
| 5 | Corporate entity (pessoa colectiva) |
| 6 | Public-sector body |
| 70, 74, 75 | Inheritance / special non-resident |
| 71 | Non-habitual resident (NHR scheme) |
| 72 | Investment fund |
| 77 | ATM special attribution |
| 78 | Non-resident (other) |
| 8 | Sole trader / ENI (historic) |
| 90, 91 | Condominium or cooperative |
| 98 | Non-resident without NIF |
Worked example with a fake NIF
Take the obviously-fake number 545259045 (chosen so it does not correspond to any real taxpayer):
- Digits 1–8: 5 4 5 2 5 9 0 4
- Weighted sum: 5×9 + 4×8 + 5×7 + 2×6 + 5×5 + 9×4 + 0×3 + 4×2 = 45+32+35+12+25+36+0+8 = 193
- Remainder: 193 mod 11 = 6
- Control: 11 − 6 = 5
- 9th digit: 5 — matches, so the check digit passes
- Prefix 5 → Corporate entity (pessoa colectiva)
Paste that number into the tool above to see the identical breakdown live.
Privacy and limitations
Every calculation happens locally. No NIF you enter is transmitted to any server. The tool confirms structural validity only — it cannot tell you whether a NIF has been assigned by AT or whether the associated taxpayer is currently active. For authoritative confirmation, use the AT online portal or the VIES system for EU VAT cross-border queries.