FastPII Docs
Detectors

NIP

Detect and validate Polish tax identification numbers with weighted Mod 11 checksum.

Purpose

Use the nip detector for Polish tax identification numbers (NIP - Numer Identyfikacji Podatkowej).

Detector Name

nip

Supported Formats

  • 10 digits: NNNNNNNNNN
  • With dashes: NNN-NNN-NN-NN

FastPII strips dashes before validation.

Validation Logic

  1. Remove dashes and spaces.
  2. Require exactly 10 digits.
  3. Run the weighted Mod 11 checksum.

Checksum Algorithm

  1. Multiply each digit by weights [6, 5, 7, 2, 3, 4, 5, 6, 7] (first 9 digits).
  2. Sum the products.
  3. Take sum % 11.
  4. Compare the result with the 10th digit.

Python Examples

from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack

engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.detect("NIP: 5260250274", detector_names=["nip"])

Validate a value directly

from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack

engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.validate("5260250274", "nip")

print(result.is_valid)

Detect in free text

from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.pl import PolishPack

engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(PolishPack())
result = engine.detect("NIP: 5260250274")

for finding in result.findings:
    print(finding.type, finding.value)

Limitations

  • NIP is specific to Polish tax identification.
  • The detector relies on context words or explicit formatting to avoid false positives on other 10-digit numbers.

On this page