How to check a NIF number is valid: format and check digit
A Portuguese NIF is only nine digits long, yet a single wrong digit can stall a bank application, a property deed or a payroll record. Numbers get mistyped in emails, transposed on forms and misread from photographs, and because a NIF looks like a random string, the human eye is poor at spotting the error. The good news is that a NIF is not random at all. It has a structure, and its last digit is a check digit calculated from the other eight, which means you can test a number yourself before you hand it to anyone. This post explains the format, works through the check digit calculation with a clearly labelled example, and shows how to spot the most common mistakes.
One boundary first. Checking that a number is correctly formed is not the same as checking that it belongs to a particular person. A number can pass every format test in this post and still be someone else's number, or a number that was never issued. Only Financas holds the record that ties a NIF to a name, through its services at Portal das Financas. Format checks catch typing errors. They do not prove identity, and you should never treat them as proof that a number is yours.
The 9 digit format, block by block
A personal NIF has exactly nine digits, written as one continuous string with no letters, spaces or dashes in the number itself. The first digit tells you something about the type of holder. Individual taxpayers have numbers beginning with 1, 2, 3 or 4 in older series, and newer personal series also begin with other digits as ranges have expanded over time, including series beginning with 5 in some allocations for individuals in recent years, so the first digit alone is not a complete test for a personal number. Company and organisation numbers follow their own ranges, which is why you should not judge a number purely by its opening digit unless you know which series it should belong to.
The middle digits are the sequential body of the number, allocated as numbers are issued. They carry no public meaning about where you live, when you were born or when you applied, so do not try to read information into them. The ninth and final digit is different: it is the check digit, and it is calculated from the first eight digits using a fixed method. That last digit is what makes self checking possible.
How the check digit works
The Portuguese check digit uses a weighted calculation, similar in spirit to the method used on many national identification numbers. Here is the method, step by step.
- Take the first eight digits of the NIF, ignoring the ninth digit for now.
- Multiply the first digit by 9, the second by 8, the third by 7, the fourth by 6, the fifth by 5, the sixth by 4, the seventh by 3 and the eighth by 2.
- Add all eight results together to get a total.
- Divide the total by 11 and note the remainder.
- Subtract the remainder from 11. If the result is 10 or 11, the check digit is 0. Otherwise, the result is the check digit.
- Compare your result with the ninth digit of the number. If they match, the number is correctly formed.
A worked example with an invented number
The following number is invented purely to demonstrate the arithmetic, and it is not presented as any real person's NIF: 123456789. Take the first eight digits, 12345678. Multiply in order: 1 times 9 is 9, 2 times 8 is 16, 3 times 7 is 21, 4 times 6 is 24, 5 times 5 is 25, 6 times 4 is 24, 7 times 3 is 21 and 8 times 2 is 16. The total is 156. Dividing 156 by 11 gives 14 with a remainder of 2, because 14 times 11 is 154. Subtract: 11 minus 2 is 9. The expected check digit is 9, and the ninth digit of the example number is 9, so this invented number is correctly formed. Change any single digit in it and the calculation will normally fail, which is exactly the point of the system.
Spotting a wrong number before it causes damage
Most real world errors are simple. Two digits are swapped when someone copies a number by hand. A 1 is read as a 7, or a 0 as an 8, from a photograph of a document. A digit is dropped, leaving eight, or a digit is repeated, leaving ten. The check digit catches the great majority of single digit errors and transpositions, so run the calculation whenever a number has passed through human hands, especially if it arrived by phone, handwriting or a forwarded message.
Where does this matter most? Anywhere the number is being recorded by someone else. When you give your NIF to a bank, an employer, a landlord or a lawyer, read it back digit by digit and ask them to confirm what they typed. A wrong digit on a property deed or an employment record is a correction job that takes far longer than a ten second check. Our posts on the NIF for a Portuguese bank account and what banks ask for and the NIF for a job start date in Portugal and employer deadlines both show points in those processes where a mistyped number typically surfaces, usually at the worst moment.
What a format check cannot tell you
A correctly formed number might still be unissued, issued to a different person, or attached to a record with outdated details. If a bank or an employer tells you a number was rejected, do not assume the digits are wrong: the mismatch may be between the number and the name or date of birth they hold. In that case the fix is not a new number, because a person keeps one NIF for life. The fix is to correct the underlying record, and our post on correcting details on your NIF record, including what proof is needed, explains how that works at Financas.
You also cannot use the format to recover a lost number. If you have lost your NIF, the number still exists on your Financas record and on documents issued when it was allocated, such as the confirmation you received when it was granted. Check old emails and paperwork first. If you applied through a service, ask the service to confirm the number from its records. Never apply again as if you were a new taxpayer, because a duplicate record creates a much bigger problem than a lost piece of paper.
Checking a number you have just received
When your own NIF is issued, do three things straight away. First, count the digits: there must be nine. Second, run the check digit calculation once, while the confirmation is in front of you, so you know the number you are storing is the number that was issued. Third, store it exactly as issued, in a note you control, and copy and paste from that note rather than retyping it each time. Most future errors happen at the retyping stage, not at issue.
If you have not applied yet and speed matters, preparation is what keeps the timeline short. Clear documents and consistent details are the whole game, as our guide on how long a NIF takes in Portugal explains, and our guide on why NIF applications get delayed and how to avoid it covers the document errors that slow filings down. A number that is issued correctly, checked once and stored carefully will serve you for decades without ever needing a second thought.
Finally, treat your NIF with the same care as any identification number. Share it with organisations that have a genuine reason to record it, such as banks, employers, landlords and official bodies. You do not need to publish it, print it on general correspondence or give it to anyone who asks casually. The official background on Portuguese public services at gov.pt, the Portuguese government portal is a sensible starting point if you want to confirm which bodies are official before you share any personal number.
Business numbers and other taxpayers
The check digit method in this post is the standard validation used for Portuguese tax numbers, and the same nine digit structure applies beyond individuals. Companies, sole traders acting under their personal number, public bodies and other entities all hold tax numbers in the same overall system, allocated in different series. That is why a landlord may give you a company number for a rental contract, or a client may give you an entity number for a receipt, and the digits still follow the format described here. Do not be confused if the first digit differs from your own personal number: different series exist for different types of holder. What stays constant is the structure, nine digits with a check digit at the end, and the habit worth keeping is the same in every case. When a number matters to a contract, a payment or a filing, verify its form before you rely on it, and confirm ownership through the organisation itself rather than through arithmetic.
Need your NIF handled remotely? Quick NIF checks your documents first and only requests payment if a NIF can be obtained for you. Standard is EUR 99 plus VAT where it applies, Urgent is EUR 145 plus VAT where it applies, foreign businesses are exempt from the VAT, and the government fee is EUR 0. A NIF is also free in person at Financas if you would rather apply yourself.
Apply for a free document check for your NIF
See Quick NIF pricing for Standard and Urgent NIF applications for the full breakdown, including the included fiscal representation.
Questions, answered
How many digits does a Portuguese NIF have?
A NIF has exactly nine digits, written as one continuous string with no letters. If a number you have been given has eight digits or ten digits, something was dropped or added when it was copied.
What is the NIF check digit and how is it calculated?
The ninth digit is a check digit. Multiply the first eight digits by 9, 8, 7, 6, 5, 4, 3 and 2 in order, add the results, divide by 11 and subtract the remainder from 11. If the result is 10 or 11 the check digit is 0, otherwise it is the result, and it should match the ninth digit.
Does a valid check digit prove a NIF belongs to someone?
No. A correct check digit only proves the number is correctly formed. It does not prove the number was issued, or that it belongs to a particular person. Only the Financas record ties a NIF to a name.
What should I do if my NIF fails the check digit test?
First, recheck the number against the original confirmation, because most failures are copying errors. If the issued number itself appears wrong, or a bank rejects it, contact Financas or your fiscal representative so the record can be checked and corrected if needed.
Can I recover a lost NIF by calculating it?
No. The check digit cannot reconstruct a lost number. Look for the original confirmation, check documents issued when the number was granted, or ask the service that obtained it for you to confirm it from its records.