Portugal NIF Generator
Generate 9-digit Portuguese NIF / NIPC tax numbers with the mod-11 check digit — synthetic test data only
For Development & Testing Purposes Only - Synthetic Mock Data
Settings
1 valueGenerates one value with a valid checksum. Press ⌘/Ctrl+Enter for a fresh one.
Generated value
No value yet
Set options, then press Generate.
Generated values are valid in shape but randomized (Test Data).
Examples
Generate a tax number
NIF / NIPC · GeneratePT501964843A company-format value starting with 5 and ending in check digit 3.
Validate a pasted value
501964843Valid — 9 digits with check digit 3Validation accepts the value with or without the PT prefix and recomputes the check digit.
Reject a wrong check digit
PT501964844Invalid — check digit is 4 but the first 8 digits require 3The validator names the expected digit so the failing branch is visible in a test log.
About this tool
The Portugal NIF Generator produces one 9-digit Portuguese tax number, the NIF used by individuals and the NIPC used by companies. The first digit indicates the taxpayer type, with 1–3 used for individuals and 5 for companies, and the ninth digit is a mod-11 check digit.
Generation derives the check digit from the first eight digits, so every result passes validation. Validation accepts an optional PT prefix and separators, recalculates the check digit and reports an unsupported leading digit separately.
These are synthetic values for QA and development, never for real applications, KYC checks, tax filings, identity documents or impersonation. A random value can coincide with a real, issued number, and DevTools accepts no liability for how generated data is used. Everything runs locally in your browser.
What this tool does not do
- Generates the NIF/NIPC shape only; NISS has a separate tool.
- Validation cannot confirm that a number is registered or active.
- A random value can coincide with a real taxpayer's number.
- The tool does not generate other Portuguese identifiers such as the social security NISS.
How to use this tool
Choose the NIF option
The tool is pinned to the Portuguese NIF / NIPC, which uses 9 digits with a mod-11 check digit.
Generate a value
Click Generate to create one 9-digit number whose leading digit and check digit agree.
Validate or copy
Switch to Validate to check a pasted value, or copy the result and download it as a .txt file.
Use cases
Invoice and tax fixtures
Fill Portuguese invoice and tax forms with a number that passes the mod-11 check instead of a real taxpayer's NIF.
Onboarding forms
Seed individual and company signup flows with values whose leading digit matches the taxpayer type.
Prefix-handling tests
Check that your parser accepts both the bare nine digits and the PT-prefixed form.
Portuguese NIF and NIPC rules
| Part | Rule |
|---|---|
| Length | 9 digits |
| Taxpayer type | First digit 1–3 for individuals, 5 for companies |
| Check digit | 9th digit, mod 11 over the first 8 digits |
| Prefix | An optional PT prefix is accepted and ignored |
| Validation | Recalculates the check digit and flags unsupported prefixes |
The check digit covers the nine digits only; a PT prefix never enters the calculation.
Common mistakes
Mistake:Using a company prefix for a person
Fix:First digits 1–3 mark individuals and 5 marks companies; test both if your form distinguishes them.
Mistake:Dropping the check digit
Fix:The ninth digit is required; an eight-digit value never passes validation.
Mistake:Including PT in the checksum
Fix:The check digit covers the nine digits only; the prefix is presentation data.
Frequently asked questions
Are these real Portuguese NIF numbers?
No. Every value is synthetic test data for QA and development and cannot be used for real tax filings, invoices, KYC checks, or identity documents; DevTools accepts no liability for how generated data is used.
What is the difference between a NIF and a NIPC?
Both are the same nine-digit tax number. NIF is the name used for individuals and NIPC for companies, and the first digit shows the taxpayer type: 1–3 for individuals and 5 for companies.
How is the check digit calculated?
The first eight digits are multiplied by weights 9 down to 2, summed and taken modulo 11. The ninth digit is 11 minus that remainder, and a result of 10 or 11 becomes 0.
Can a generated NIF match a real taxpayer?
It can. The mod-11 check only confirms the number is well formed, so a random value may coincide with a real taxpayer's number. Keep generated values out of production data.
Should fixtures keep the PT prefix?
Either form works. The validator accepts the bare nine digits and the PT-prefixed version, and the prefix never enters the check-digit calculation.
References & standards
Related tools
Portugal NISS Generator
Generate synthetic 11-digit Portuguese NISS social security numbers for people and companies, with mod-10 check digits.
SEPA IBAN Generator
Generate SEPA-eligible IBAN and BIC pairs with ISO 7064 Mod 97-10 checks.
VAT Number Generator
Generate VAT numbers for EU, UK, Switzerland, Norway and global tax integration testing.
National Identity Generator
Generate and validate national ID numbers for testing (TR, US, DE, UK, SA, AE, QA, KW, CA, ES, BR, FR, IT, NL, SE, NO, EG, SG)
Tax ID Validator
Auto-detect and validate VAT, EIN, TIN and GST identifiers with batch checksum reporting.