Skip to main content

Introduction

anonyma finds personal data in text and JSON — e-mail addresses, phone numbers, card numbers, national IDs and 23 other categories — and replaces it: with a label, a mask, a pseudonym, a synthetic value, a hash, a ciphertext, or a reversible token that can be put back later.

It is a TypeScript library with no runtime dependencies. It runs in your process, on Node.js, Bun, Deno, Cloudflare Workers and in browsers; nothing is sent anywhere. The playground on this site is the library itself, running in your browser.

npm install anonyma
import { anonymize } from "anonyma";

anonymize("Mail ana@example.com, CPF 529.982.247-25", { preset: ["lgpd", "gdpr"] }).text;
// "Mail [REDACTED], CPF [REDACTED]"

What you can do with it​

You want to…Use
Clean a string or an object in one callanonymize(), anonymizeObject() — Quick start
Follow a regulation, or severalpresets, alone or combined — Compliance presets
Send prompts to an LLM and get the real values backtokens and vaults — Protect LLM prompts
Clean logs, exports and data files; check them in CIthe anonyma command — Scrub files
Keep personal data out of API responsesExpress, Hono and Fetch middleware — HTTP middleware
Build a pipeline once, reuse it, stream itanonyma/engine — Span engine
Keep data joinable, rotate keys, honour erasurekeyed tokens — Keys and token vaults
Prove what was doneaudit chains and receipts — Audit trail and receipts

Principles​

  • The data stays where it is. No network, file-system or process API in the library; CI checks it on every change, along with the absence of runtime dependencies.
  • Detection you can trust. Validating detectors check digits (Luhn, mod-97, mod-11, CPF, CNPJ, …) and context, so version strings and order numbers are left alone, and no detected character is left in the output.
  • Edge first. Web Crypto and WHATWG streams only; the build is tested on Bun, Deno and Cloudflare Workers.
  • Evidence without data. Audit records and receipts say what was replaced, never what it was.

Where next​