secretstuff

pii detection and redaction. 150+ entity types. reversible.

pypi github

// overview

secretstuff identifies, redacts, and reverses personally identifiable information in text using gliner models. it detects 150+ types of pii, replaces them with configurable dummy values, and stores mappings so you can restore originals when needed.

// installation

pip install secretstuff

// quick start

from secretstuff import SecretStuff

ss = SecretStuff()

text = "Contact John Smith at john@example.com or 555-123-4567"

# detect pii
entities = ss.detect(text)
for entity in entities:
    print(f"{entity.type}: {entity.text}")

# redact pii
redacted = ss.redact(text)
print(redacted.text)
# "Contact [PERSON] at [EMAIL] or [PHONE]"

# reverse redaction
original = ss.reverse(redacted)
print(original)
# "Contact John Smith at john@example.com or 555-123-4567"

// api reference

SecretStuff()

main class. initializes the gliner model for entity detection.

detect(text: str) -> list[Entity]

identifies all pii entities in the text.

entity.type str — entity type (e.g. "email", "phone")
entity.text str — the matched text
entity.start int — start position in text
entity.end int — end position in text

redact(text: str) -> RedactedResult

replaces all pii with dummy values. returns result with text and mapping.

reverse(redacted: RedactedResult) -> str

restores original text from the redacted result's stored mappings.

// entity types

150+ entity types including:

powered by gliner's zero-shot ner capabilities — no training required for new entity types.