Quickstart
Install
Section titled “Install”npm install textsiftOne package, two entry points so browsers never bundle native code:
// Browser / Node-via-WASM. WebGPU + Zig+SIMD128 WASM. No native binary.import { PrivacyFilter } from "textsift/browser";
// Node native — auto-picks the platform's GPU fast path (Metal on macOS,// Vulkan on Linux, Dawn on Windows). Falls back to WASM if no GPU is// available. The right per-platform .node binary is pulled in via// optionalDependencies at install time.import { PrivacyFilter } from "textsift";The examples below use the browser entry, but the API is identical for both.
Redact
Section titled “Redact”import { PrivacyFilter } from "textsift/browser";
const filter = await PrivacyFilter.create();
const { redactedText, spans } = await filter.redact( "Please email me at jane.doe@example.com about invoice 4511.",);// redactedText = "Please email me at [private_email] about invoice [account_number]."// spans = [ { label: "private_email", ... }, { label: "account_number", ... } ]Detect (no redaction applied)
Section titled “Detect (no redaction applied)”const { spans, containsPii } = await filter.detect( "Call me at (555) 123-4567.",);// spans = [ { label: "private_phone", start: 11, end: 25, text: "(555) 123-4567", ... } ]// containsPii = trueconst results = await filter.redactBatch([ "First message.", "Second message with PII: jane@example.com.",]);Pick a backend
Section titled “Pick a backend”By default PrivacyFilter.create() picks WebGPU when available, otherwise the WASM backend. Force a specific path:
// Fastest: WGSL compute shaders, requires WebGPU + shader-f16.const gpu = await PrivacyFilter.create({ backend: "webgpu" });
// Universal: Zig + WASM + SIMD128. Works everywhere. Multi-threaded// when the page is cross-origin-isolated (COOP/COEP headers set).const wasm = await PrivacyFilter.create({ backend: "wasm" });See the Backends page for the full compatibility table.
Dispose when done
Section titled “Dispose when done”filter.dispose();Releases GPU buffers and WASM memory. Safe to call multiple times.
More than the library
Section titled “More than the library”Same engine, four distribution surfaces:
- CLI —
npx textsift redact file.txtfor shell pipelines + scripts. - Pre-commit hook — block commits containing PII before they land.
- GitHub Action —
uses: teamchong/textsift@v1to scan PRs with inline annotations. - Tabular data —
classifyColumns+redactTablefor CSV / DB-dump audits.
The Faker mode playground shows synthetic-data redaction in action — useful when downstream code expects PII-shaped inputs (test fixtures, sales demos, vendor data sharing).