Skip to main content
Rehydra is an on-device PII (Personally Identifiable Information) anonymization module designed for high-privacy AI workflows. It detects and replaces sensitive information with placeholder tags while maintaining an encrypted mapping for later rehydration.

Quick Start

Get up and running in under 5 minutes

Why Rehydra?

When processing text through AI services (translation, summarization, etc.), you often need to protect sensitive information. Rehydra enables privacy-preserving workflows:
1

Anonymize

Detect and replace PII with placeholder tags before sending to AI
2

Process

Send anonymized text to any AI service safely
3

Rehydrate

Restore original values after processing

Key Features

Structured PII Detection

Regex-based detection for emails, phones, IBANs, credit cards, IPs, URLs, and more

Soft PII Detection

ONNX-powered NER model for names, organizations, and locations

Semantic Enrichment

AI/MT-friendly tags with gender and location attributes for better translations

Secure Encryption

AES-256-GCM encrypted storage of original PII values

Cross-Platform

Works identically in Node.js, Bun, and browsers

Session Management

Persistent storage providers for multi-turn conversations

Example Workflow

Here’s how Rehydra protects PII during translation:
import { createAnonymizer, decryptPIIMap, rehydrate, InMemoryKeyProvider } from 'rehydra';

// Setup
const keyProvider = new InMemoryKeyProvider();
const anonymizer = createAnonymizer({
  ner: { mode: 'quantized' },
  keyProvider
});
await anonymizer.initialize();

// 1. Anonymize before sending to AI
const original = 'Contact John Smith at [email protected]';
const result = await anonymizer.anonymize(original);
// → "Contact <PII type="PERSON" id="1"/> at <PII type="EMAIL" id="1"/>"

// 2. Send to translation API (PII is protected!)
const translated = await translateAPI(result.anonymizedText);
// → "Kontaktieren Sie <PII type="PERSON" id="1"/> unter <PII type="EMAIL" id="1"/>"

// 3. Restore original values
const piiMap = await decryptPIIMap(result.piiMap, await keyProvider.getKey());
const final = rehydrate(translated, piiMap);
// → "Kontaktieren Sie John Smith unter [email protected]"

Platform Support

EnvironmentVersionNotes
Node.js≥ 18.0.0Uses native onnxruntime-node
Bun≥ 1.0.0Requires onnxruntime-web
BrowsersChrome 86+, Firefox 89+, Safari 15.4+, Edge 86+Uses OPFS for model storage

Next Steps