Skip to main content
Rehydra supports two closely related ways to protect sensitive text: pseudonymize for reversible workflows and anonymize for irreversible ones.

The Two Modes

ModeWhat happensCan you restore originals later?Typical use
pseudonymizeRehydra replaces detected values with placeholders and returns an encrypted piiMapYesApps, agents, and workflows that need later rehydration
anonymizeRehydra replaces detected values with placeholders and discards the original-value mappingNoOne-way redaction and irreversible sharing
import { createAnonymizer } from 'rehydra';

const reversible = createAnonymizer({ mode: 'pseudonymize' });
const irreversible = createAnonymizer({ mode: 'anonymize' });

Shared Processing Model

Both modes use the same high-level flow:
1

Detect

Rehydra runs enabled recognizers and optional NER to identify sensitive spans.
2

Resolve

Overlaps are resolved using type priority and confidence rules.
3

Replace

Original values are swapped for stable <PII .../> placeholders.
4

Store or discard

In pseudonymize mode Rehydra encrypts the mapping; in anonymize mode it does not keep one.

Placeholder Output

Rehydra uses XML-like placeholders so downstream systems can safely process the text while preserving structure.
<PII type="EMAIL" id="1"/>
<PII type="PERSON" id="1"/>
When semantic enrichment is enabled, placeholders can include extra attributes:
<PII type="PERSON" gender="female" id="1"/>
<PII type="LOCATION" scope="city" id="2"/>

Choosing the Right Mode

Use pseudonymize when:
  • You need to restore the original values later
  • You are building an application flow around rehydration
  • You want encrypted mappings for sessions or agent workflows
Use anonymize when:
  • You want irreversible protection
  • You are preparing text for one-way sharing or analysis
  • You do not want to manage keys or stored mappings
pseudonymize naturally connects to rehydration, encryption, and key management. anonymize is simpler, but it still depends on the same recognizers, type system, and configuration model.

Next Steps

Rehydration

Learn how reversible workflows restore original values.

Configuration

See which settings shape detection and output behavior.