nif.mod11
Validate a Portuguese NIF: free checker and Mod-11 rules
Check any Portuguese NIF instantly: 9 digits, valid prefix and Mod-11 check digit. Plus how the algorithm works and the most common errors.
Check a NIF
This checks the format and check digit only. It does not confirm the NIF is registered with AT.
Checking NIFs one by one? SAFTCheck validates every NIF in your SAF-T file at once, along with ATCUD, dates and encoding.
Validate your SAF-T, freeWhat a NIF is
A NIF (Número de Identificação Fiscal) is the 9-digit Portuguese tax ID issued by AT to individuals, companies and other entities. SAF-T files reference NIFs in three required spots: Header.TaxRegistrationNumber, every Customer.CustomerTaxID, and every Supplier.SupplierTaxID. Customers and suppliers based abroad carry their own country's tax ID there, so SAFTCheck applies the Portuguese check only when their billing address country is PT.
The Mod-11 algorithm
The 9th digit is a check digit computed from the first eight:
- Multiply digit 1 by 9, digit 2 by 8, …, digit 8 by 2.
- Sum the products.
- Take the sum modulo 11.
- If the result is 0 or 1, the check digit is 0.
- Otherwise the check digit is 11 − result.
# Worked example: 503504564
# digits 5 0 3 5 0 4 5 6
# weights 9 8 7 6 5 4 3 2
# products 45 0 21 30 0 16 15 12 → sum 139
# 139 mod 11 = 7
# 11 - 7 = 4
# check = 4 → matches digit 9 ✓
Allowed first digits
| Range | Used by |
|---|---|
| 1, 2, 3 | Individuals (residents) |
| 5 | Companies (LDA, SA, etc.) |
| 6 | Public administration |
| 8 | Empresário em Nome Individual (ENI) |
| 9 | Other entities |
| 45, 70, 71, 72, 74, 75, 77, 79, 90, 91, 98, 99 | Specific cases (e.g. heritage, condominium, foreign-resident) |
Special cases
999999990is the AT-reserved placeholder for "Consumidor final" (anonymous retail buyer). It is allowed inCustomer.CustomerTaxIDfor retail-style invoices.- Any NIF that fails the Mod-11 check is rejected, even if the digits look plausible.
How to fix
The fix depends on which side has the wrong digit:
- Header.TaxRegistrationNumber wrong — your own NIF is misconfigured in the ERP. Update the company profile and re-export — or, if you only need to ship this one file, use the inline editor to patch the value in place.
- Customer or Supplier NIF wrong — typo or stale record. Correct it in the master data and re-export — or patch the offending occurrence with the inline editor when re-exporting is not an option.
SAFTCheck never invents a NIF; the inline editor only applies the value you supply. We do not auto-suggest tax IDs.
Related
- ATCUD format — the document-level unique code, separate from NIFs.
- Inline editor — patch a NIF in place once you have the correct value.