Detect, redact, tokenize, and mask PII in Java. 80+ entity types, 30+ countries, works offline with zero external dependencies.
- Works offline, zero external dependencies — No API key needed for local detection. No network calls. Only Gson for JSON.
- 80+ PII entity types across 30+ countries with checksum validation (Luhn, IBAN mod-97, Verhoeff, etc.)
- 8 operations: detect, redact, tokenize, detokenize, mask, hash, encrypt, synthesize
- Compliance-ready — Target GDPR, HIPAA, PCI-DSS entities with built-in filters
- Optional NLP upgrade — Add API key to detect names, addresses, organizations (60+ additional entities)
- Batch processing, async support via
CompletableFuture, typed exceptions
| Feature | Blindfold | Presidio | regex-only |
|---|---|---|---|
| Entity types (local) | 80+ | ~20 | Custom |
| Countries | 30+ | ~5 | Custom |
| Checksum validation | Luhn, mod-97, Verhoeff, ... | Partial | No |
| Zero external deps | Yes (only Gson) | No (spaCy) | Yes |
| NLP upgrade path | Yes (API) | Yes (built-in) | No |
| Tokenize/detokenize | Yes | No | No |
- Sanitize LLM prompts — Strip PII before sending to OpenAI, Anthropic, etc.
- PII-safe RAG pipelines — Redact before embedding, restore after retrieval
- Log scrubbing — Anonymize data in logs and data pipelines
- GDPR/HIPAA compliance — Filter entities relevant to your compliance scope
- Synthetic test data — Format-preserving fake data generation
- Java 11+
- Gson (included as dependency)
<dependency>
<groupId>dev.blindfold</groupId>
<artifactId>blindfold-sdk</artifactId>
<version>1.0.0</version>
</dependency>implementation 'dev.blindfold:blindfold-sdk:1.0.0'import dev.blindfold.sdk.Blindfold;
import dev.blindfold.sdk.models.*;
// No API key = automatic local mode
Blindfold client = new Blindfold();
// Detect PII locally — no API key, no network call
DetectResponse result = client.detect("Email [email protected], SSN 123-45-6789");
for (DetectedEntity entity : result.getDetectedEntities()) {
System.out.println(entity.getType() + ": " + entity.getText()
+ " (score: " + entity.getScore() + ")");
}
// Email Address: [email protected] (score: 0.95)
// Social Security Number: 123-45-6789 (score: 1.0)
// Redact PII locally
RedactResponse redacted = client.redact("Email [email protected], SSN 123-45-6789");
System.out.println(redacted.getText());
// "Email, SSN"Tokenize PII before sending to any LLM. The AI never sees real data.
import dev.blindfold.sdk.Blindfold;
Blindfold bf = new Blindfold(); // Free local mode
// 1. Tokenize PII
var safe = bf.tokenize("My name is John Smith, email [email protected]");
// safe.getText() → "My name is <Person_1>, email <Email Address_1>"
// 2. Send to GPT — PII never reaches OpenAI
String aiResponse = callOpenAI(safe.getText());
// 3. Restore original data
var result = bf.detokenize(aiResponse, safe.getMapping());
System.out.println(result.getText());import dev.blindfold.sdk.Blindfold;
Blindfold bf = new Blindfold();
var safe = bf.tokenize("My name is John Smith, email [email protected]");
// Send to Claude via your preferred Anthropic Java client
String aiResponse = callClaude(safe.getText());
var result = bf.detokenize(aiResponse, safe.getMapping());
System.out.println(result.getText());Works with any AI provider: OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Azure OpenAI, LangChain, LlamaIndex, Vercel AI SDK, CrewAI — see all integrations.
For names, addresses, organizations, and 60+ entity types, add your API key:
- Sign up at blindfold.dev
- Get your API key at app.blindfold.dev/api-keys
- Set environment variable:
BLINDFOLD_API_KEY=sk-***
// With API key — auto-switches to NLP-powered API
Blindfold client = new Blindfold("sk-...");
DetectResponse result = client.detect("John Smith lives at 123 Oak Street");import dev.blindfold.sdk.Blindfold;
import dev.blindfold.sdk.BlindfoldOptions;
// Local mode (no API key) — regex-based detection
Blindfold client = new Blindfold();
// API mode (with API key) — NLP-powered detection
Blindfold client = new Blindfold("sk-...");
// Full configuration
Blindfold client = new Blindfold(BlindfoldOptions.builder()
.apiKey("sk-...")
.region("eu") // "eu" or "us"
.maxRetries(3)
.retryDelay(500) // milliseconds
.timeout(30000) // milliseconds
.userId("user-123")
.build());
// Force local mode even with an API key (useful for latency-critical paths)
Blindfold client = new Blindfold(BlindfoldOptions.builder()
.apiKey("sk-...")
.mode("local")
.build());Replace sensitive data with reversible tokens (e.g., <Person_1>).
TokenizeResponse response = client.tokenize("Contact John Doe at [email protected]");
System.out.println(response.getText());
// "Contact <Person_1> at <Email Address_1>"
System.out.println(response.getMapping());
// {"<Person_1>": "John Doe", "<Email Address_1>": "[email protected]"}
// Filter by entity types
TokenizeResponse filtered = client.tokenize(
"Email [email protected] and [email protected]",
List.of("email address")
);Restore original values from tokens. Runs client-side — no API call.
DetokenizeResponse original = client.detokenize(
"AI response for <Person_1>",
response.getMapping()
);
System.out.println(original.getText());
// "AI response for John Doe"Find PII entities in text.
DetectResponse response = client.detect("Call (555) 123-4567");
// Filter by entity types
DetectResponse filtered = client.detect(
"Email [email protected], SSN 123-45-6789",
List.of("email address")
);Permanently remove sensitive data.
RedactResponse response = client.redact("SSN: 123-45-6789");
System.out.println(response.getText());
// "SSN:"
// Filter by entity types
RedactResponse filtered = client.redact("SSN: 123-45-6789", List.of("social security number"));Partially hide sensitive data (e.g., ****-****-****-1234).
MaskResponse response = client.mask(
"Card: 4111-1111-1111-1111",
4, // chars to show
true, // from end
"*", // masking character
null // entities filter (null = all)
);
System.out.println(response.getText());
// "Card: ***************1111"Replace data with deterministic hashes (useful for analytics/matching).
HashResponse response = client.hash(
"Email [email protected]",
"sha256", // hash type: "md5", "sha1", "sha256"
"HASH_", // prefix
16, // hash length
null // entities filter
);Encrypt sensitive data using AES (reversible with key).
EncryptResponse response = client.encrypt(
"Email [email protected]",
"my-secret-key-16chars"
);Replace real data with realistic fake data. Works offline with format-preserving generation.
// Works offline — no API key required
Blindfold client = new Blindfold();
SynthesizeResponse response = client.synthesize("Email [email protected], SSN 123-45-6789");
System.out.println(response.getText());
// "Email [email protected], SSN 847-29-3156"
// With API key — NLP-powered synthesis (names, addresses, etc.)
SynthesizeResponse response = client.synthesize("John lives in New York", "en", null);
System.out.println(response.getText());
// "Michael lives in Boston"Process multiple texts in a single request (max 100 texts):
BatchResponse<DetectResponse> result = client.detectBatch(
List.of("Contact John Doe", "[email protected]", "No PII here")
);
System.out.println(result.getTotal()); // 3
System.out.println(result.getSucceeded()); // 3
System.out.println(result.getFailed()); // 0
for (DetectResponse item : result.getResults()) {
System.out.println(item.getDetectedEntities());
}
// With entity filter
BatchResponse<TokenizeResponse> filtered = client.tokenizeBatch(
List.of("[email protected]", "SSN 123-45-6789"),
List.of("email address")
);Batch methods available: detectBatch, tokenizeBatch.
import dev.blindfold.sdk.BlindfoldAsync;
BlindfoldAsync asyncClient = new BlindfoldAsync(
BlindfoldOptions.builder().build()
);
CompletableFuture<DetectResponse> future = asyncClient.detectAsync("Email [email protected]");
DetectResponse response = future.get();
// All operations have async variants:
// detectAsync, tokenizeAsync, detokenizeAsync, redactAsync,
// maskAsync, hashAsync, encryptAsync, synthesizeAsyncThe built-in regex scanner works offline with no external dependencies. Use it directly for fine-grained control:
import dev.blindfold.sdk.regex.PIIScanner;
import dev.blindfold.sdk.regex.PIIMatch;
// Default: US locale
PIIScanner scanner = new PIIScanner(List.of("us", "eu"));
List<PIIMatch> matches = scanner.detect("IBAN: DE89 3704 0044 0532 0130 00");
for (PIIMatch match : matches) {
System.out.printf("%s: %s (%.2f) [%d:%d]%n",
match.getEntityType(), match.getText(), match.getScore(),
match.getStart(), match.getEnd());
}// US + EU entities
PIIScanner scanner = new PIIScanner(List.of("us", "eu"));
// UK entities
PIIScanner scanner = new PIIScanner(List.of("uk"));
// All locales
Blindfold client = new Blindfold(BlindfoldOptions.builder()
.locales(List.of("us", "eu", "uk", "de", "fr", "es", "it"))
.build());Available locales: us, uk, eu, de, fr, es, it, pt, pl, cz, sk, ru, nl, ro, dk, se, no, be, at, ie, fi, hu, bg, hr, si, lt, lv, ee, ca, ch, au, nz, in, jp, kr, za, tr, il, ar, cl, co, br
import dev.blindfold.sdk.errors.AuthenticationException;
import dev.blindfold.sdk.errors.ApiException;
import dev.blindfold.sdk.errors.NetworkException;
try {
client.tokenize("...");
} catch (AuthenticationException e) {
// Handle invalid API key (401)
} catch (ApiException e) {
// Handle API error (e.g. validation, rate limit)
System.out.println(e.getStatusCode());
} catch (NetworkException e) {
// Handle network issues
}Supported local entity types (80+)
| Entity Type | Locale | Validation |
|---|---|---|
| Email Address | Universal | RFC 5322 pattern |
| Credit Card Number | Universal | Luhn checksum |
| Phone Number | Universal | Format + digit count |
| IP Address (v4/v6) | Universal | Octet range |
| URL | Universal | TLD validation |
| MAC Address | Universal | Pattern |
| Date of Birth | Universal | Context-required |
| CVV/CVC | Universal | Context-required |
| Social Security Number | US | Format rules + context |
| Driver's License | US | Multi-state formats + context |
| US Passport | US | Context-required |
| Tax ID / EIN | US | Prefix validation + context |
| ZIP Code | US | Context-required + validator |
| US ITIN | US | Format validation |
| IBAN | EU | ISO 7064 mod-97 checksum |
| Postal Code | EU | DE/FR/NL patterns |
| VAT ID | EU | Country prefix + format |
| UK NI Number | UK | Format validation |
| UK NHS Number | UK | Modulus-11 checksum |
| UK Postcode | UK | Pattern |
| UK Passport | UK | Context-required |
| UK UTR | UK | Mod-11 checksum |
| German Personal ID | DE | Context-required |
| German Tax ID | DE | Check digit |
| French National ID (NIR) | FR | Check digit |
| French SIREN | FR | Luhn checksum |
| Spanish DNI | ES | Letter validation |
| Spanish NIE | ES | Letter validation |
| Spanish NSS | ES | Mod-97 checksum |
| Spanish CIF | ES | Custom checksum |
| Italian Codice Fiscale | IT | Check digit |
| Italian Partita IVA | IT | Luhn-like checksum |
| Portuguese NIF | PT | Check digit |
| Dutch BSN | NL | Modulus-11 check |
| Belgian National Number | BE | Mod-97 checksum |
| Belgian Enterprise Number | BE | Mod-97 checksum |
| Austrian SVNR | AT | Mod-11 checksum |
| Swiss AHV | CH | EAN-13 checksum |
| Irish PPS Number | IE | Mod-23 checksum |
| Polish PESEL | PL | Check digit |
| Polish NIP | PL | Check digit |
| Polish REGON | PL | Mod-11 checksum |
| Czech Birth Number | CZ | Modulus validation |
| Czech ICO (Company ID) | CZ | Mod-11 weighted checksum |
| Czech DIC (Tax/VAT ID) | CZ | ICO checksum / mod-11 |
| Czech Bank Account | CZ | Mod-11 weighted checksum |
| Slovak Birth Number | SK | Modulus validation |
| Slovak ICO | SK | Mod-11 weighted checksum |
| Slovak DIC | SK | Mod-11 divisibility |
| Romanian CNP | RO | Check digit |
| Romanian CUI | RO | Mod-11 checksum |
| Danish CPR | DK | Date validation |
| Danish CVR | DK | Mod-11 checksum |
| Swedish Personnummer | SE | Luhn algorithm |
| Swedish Organisationsnummer | SE | Luhn algorithm |
| Norwegian Birth Number | NO | Check digit |
| Norwegian Organisasjonsnummer | NO | Mod-11 checksum |
| Finnish HETU | FI | Mod-31 checksum |
| Finnish Y-tunnus | FI | Mod-11 checksum |
| Hungarian Tax ID | HU | Mod-11 checksum |
| Hungarian TAJ | HU | Mod-10 checksum |
| Bulgarian EGN | BG | Mod-11 checksum |
| Croatian OIB | HR | ISO 7064 MOD 11,2 |
| Slovenian EMSO | SI | Mod-11 checksum |
| Slovenian Tax Number | SI | Mod-11 checksum |
| Lithuanian Personal Code | LT | Dual-pass mod-11 |
| Latvian Personal Code | LV | Weighted checksum |
| Estonian Personal Code | EE | Dual-pass mod-11 |
| Russian INN | RU | Check digit |
| Russian SNILS | RU | Check digit |
| Canadian SIN | CA | Luhn checksum |
| Australian TFN | AU | Mod-11 checksum |
| Australian Medicare | AU | Mod-10 checksum |
| New Zealand IRD | NZ | Dual-pass mod-11 |
| Indian Aadhaar | IN | Verhoeff algorithm |
| Indian PAN | IN | Format validation |
| Japanese My Number | JP | Mod-11 checksum |
| Korean RRN | KR | Weighted checksum |
| South African ID | ZA | Luhn checksum |
| Turkish Kimlik | TR | Custom dual check |
| Israeli ID | IL | Luhn checksum |
| Brazilian CPF | BR | Check digit |
| Brazilian CNPJ | BR | Check digit |
| Argentine CUIT | AR | Mod-11 checksum |
| Chilean RUT | CL | Mod-11 with K |
| Colombian NIT | CO | Mod-11 prime weights |
Add your API key to unlock names, addresses, organizations, and 60+ additional entity types with NLP-powered detection.
MIT