Skip to content

Quickstart

Terminal window
npm install textsift

One 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.

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", ... } ]
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 = true
const results = await filter.redactBatch([
"First message.",
"Second message with PII: jane@example.com.",
]);

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.

filter.dispose();

Releases GPU buffers and WASM memory. Safe to call multiple times.

Same engine, four distribution surfaces:

  • CLInpx textsift redact file.txt for shell pipelines + scripts.
  • Pre-commit hook — block commits containing PII before they land.
  • GitHub Actionuses: teamchong/textsift@v1 to scan PRs with inline annotations.
  • Tabular dataclassifyColumns + redactTable for 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).