Skip to main content

Portugal NIF Generator

Generate valid Portuguese NIF (Tax Identification Number) for QA testing.

Waiting for generation...

About Tax Identification Number (NIF)

The Tax Identification Number (NIF), commonly referred to as the Contributor Number in Portugal, is the unique nine-digit numeric identifier assigned by the Tax and Customs Authority (AT) to individuals and corporate entities for tax purposes.

This tool generates simulated and mathematically valid Portuguese taxpayer numbers (NIF). The generator separates entity types: Individuals (initial prefixes 1, 2, 3) and Companies/Corporate entities (prefixes 5, 6, 8, 9), calculating check digit using Modulo 11.

Anatomy & Structure of Portuguese NIF

The Tax Identification Number (NIF) consists of 9 digits issued by AT:

PositionFieldLengthMeaning & RuleExample
1Prefix / Category1 digitTaxpayer category (1/2/3 Individual, 5 Company, 6 Public Body, 8 Sole Trader, 9 Funds)5
2 to 8Sequential7 digitsSequential identifier assigned by the Tax Authority (AT)0123456
9Check Digit1 digitWeighted checksum digit calculated with Modulo 11 and weights 9 to 27

NIF Validation Algorithm (Weighted Modulo 11)

The Tax Authority calculates the check digit using descending weights from 9 to 2:

DV = 11 - (sum(d_i * [9, 8, 7, 6, 5, 4, 3, 2]) % 11) | if DV >= 10, DV = 0
  1. 1. Multiply first 8 digits by weights [9, 8, 7, 6, 5, 4, 3, 2].
  2. 2. Compute sum of products.
  3. 3. Calculate remainder modulo 11: Remainder = Sum % 11.
  4. 4. Preliminary check digit: DV = 11 - Remainder.
  5. 5. If DV is 10 or 11, set DV = 0; otherwise use the calculated number.

Frequently Asked Questions (FAQ)