Installation
npm install anonyma
# or
pnpm add anonyma
# or
yarn add anonyma
The package has no runtime dependencies. Zod is an optional peer dependency, needed only for the
schemas in anonyma/schemas:
npm install zod
Requirements
- A JavaScript runtime with the Web platform: Node.js 18 or later, Bun, Deno, Cloudflare
Workers or a browser. The library uses Web Crypto, WHATWG streams and
TextEncoder, and no Node.js module. On Node.js 18, which has no globalcrypto, it loadsnode:cryptolazily. CI runs the same feature checks on every one of these runtimes; Workers run them withoutnodejs_compat. - TypeScript 5.0 or later (optional). The package ships full declarations and is written
without
any. - Zod 3.25.4 or later, or Zod 4 (optional), for
anonyma/schemas. It imports thezod/v3entry point that both provide, so its types are the same with either.
The package is published as ESM and CommonJS, and is tree-shakeable: import only what you use.
Entry points
Start with anonyma. The other entry points add features you can adopt one at a time.
| Import | What it gives you | Guide |
|---|---|---|
anonyma | detect(), anonymize(), objects, tokens, presets, batches, strategies, errors | Quick start |
anonyma/engine | Compiled pipelines with validating detectors, every strategy, chunk-safe streams | Span engine |
anonyma/vault | Session, keyed and sealed tokenizers, a key ring with rotation, token vaults | Keys and token vaults |
anonyma/ai | Chat-message and JSON sanitizers, restoration of complete and streamed model output | LLMs and AI tools |
anonyma/audit | A hash-chained audit log without personal data, signed receipts | Audit trail and receipts |
anonyma/compliance | Regulation profiles with citations, a policy parser, erasure planning | Regulations and policies |
anonyma/middleware | Scrubbing of HTTP payloads; adapters in anonyma/middleware/express and …/hono | HTTP middleware |
anonyma/mcp | A Model Context Protocol server without dependencies | LLMs and AI tools |
anonyma/stream | WHATWG TransformStream wrappers around anonymize() and tokenize() | Batches and streams |
anonyma/validators | Checksum validators: Luhn, mod-97, mod-11, CPF, CNPJ and more | Checksum validators |
anonyma/detectors | Every detector, and the registries that hold them | Detecting personal data |
anonyma/schemas | Zod schemas, function-calling tool definitions and a capability manifest (needs Zod) | LLMs and AI tools |
anonyma/crypto | Low-level Web Crypto helpers | API reference |
Companion packages
Three packages are published separately and take anonyma as a peer dependency:
anonyma-cli— theanonymacommand, to scrub and scan files of any size;anonyma-vercel-ai— middleware for the Vercel AI SDK;anonyma-mcp— a privacy proxy for any MCP server.