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
from fastpii.countries.pl import PolishPack

priority = {"nip": 95, "pesel": 100, "email": 70, "name": 50}
engine = FastPII(priority=priority)
engine.register(PolishPack())
result = engine.detect("NIP: 5260250274", detector_names=["nip"])

Convenience API

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["pl"])
result = guard.validate("5260250274", "nip")

print(result.is_valid)

Convenience API — Detect in free text

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["pl"])
result = guard.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