FastPII Docs
Guides

Redaction

Replace detected PII with type-based labels.

Redaction

Use redact() to replace each finding with its type label in brackets. This preserves the type of PII while hiding the actual value.

Basic redaction

from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.cz import CzechPack

engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register(CzechPack())

text = "Email: jan.novak@example.cz, RČ: 8001011238"
result = engine.redact(text)
print(result)

Output:

Email: [EMAIL], RČ: [RODNE_CISLO]

Using TransformationEngine directly

from fastpii.core.transform import TransformationEngine, RedactStrategy

result = engine.detect(text)
redacted = TransformationEngine.apply(result, RedactStrategy())
print(redacted)

Multi-region redaction

from fastpii import FastPII, DEFAULT_PRIORITY
from fastpii.countries.cz import CzechPack
from fastpii.countries.pl import PolishPack
from fastpii.countries.de import GermanPack

engine = FastPII(priority=DEFAULT_PRIORITY)
engine.register_many([CzechPack(), PolishPack(), GermanPack()])

text = "RČ: 8001011238, PESEL: 44051401458, Steuer-ID: 86095742719"
result = engine.redact(text)
print(result)

Output:

RČ: [RODNE_CISLO], PESEL: [PESEL], Steuer-ID: [STEUER_ID]

When to use redaction

Redaction is best when:

  • You need to know what type of PII was detected
  • Building audit logs that record PII types without values
  • Preparing reports where PII type context matters

On this page