DevTools Logo

Portugal NIF Generator

Portugal NIF Generator

Generate 9-digit Portuguese NIF / NIPC tax numbers with the mod-11 check digit — synthetic test data only

Runs in your browser

For Development & Testing Purposes Only - Synthetic Mock Data

Settings

1 value

Generates 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).

Legal Disclaimer: Generated data is for software testing and validation purposes only (e.g. verifying input masks, form validation, or database seeding). It is randomly generated and not taken from any real record, but a random value can coincidentally match a real, issued number, so never use it in real applications, payments, KYC or official forms. Using it to impersonate real people or for any fraudulent activity is illegal. DevTools accepts no liability for how generated data is used.

    Examples

    Generate a tax number

    Input
    NIF / NIPC · Generate
    Output
    PT501964843

    A company-format value starting with 5 and ending in check digit 3.

    Validate a pasted value

    Input
    501964843
    Output
    Valid — 9 digits with check digit 3

    Validation accepts the value with or without the PT prefix and recomputes the check digit.

    Reject a wrong check digit

    Input
    PT501964844
    Output
    Invalid — check digit is 4 but the first 8 digits require 3

    The 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

    1. Choose the NIF option

      The tool is pinned to the Portuguese NIF / NIPC, which uses 9 digits with a mod-11 check digit.

    2. Generate a value

      Click Generate to create one 9-digit number whose leading digit and check digit agree.

    3. 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

    PartRule
    Length9 digits
    Taxpayer typeFirst digit 1–3 for individuals, 5 for companies
    Check digit9th digit, mod 11 over the first 8 digits
    PrefixAn optional PT prefix is accepted and ignored
    ValidationRecalculates 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