FastPII Docs
Guides

Redaction

Replace detected PII with type-based labels using PrivacyGuard.redact.

PrivacyGuard.redact() replaces each finding with a label based on its type.

Basic redaction

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])
text = "Kontakt: jan.novak@email.cz, RČ 8001011238, IČO 25596641"

redacted = guard.redact(text)
print(redacted)

Output:

Kontakt: [EMAIL], RČ [RODNE_CISLO], IČO [ICO]

Type-based labels

The replacement label is built from finding.type.upper().

Examples include:

  • email[EMAIL]
  • rodne_cislo[RODNE_CISLO]
  • ico[ICO]
  • name[NAME]
  • phone[PHONE]

Keep structure while hiding values

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])
invoice = "Customer Jan Novák, IČO 25596641, email jan.novak@email.cz"

print(guard.redact(invoice))

Possible output:

Customer [NAME], IČO [ICO], email [EMAIL]

Use redact() when consumers still need to know what kind of data was removed.

On this page