Toolpal

@toolpal/pii-redact

public

v2.0published 1 download this weekMIT

Scans and redacts personal information (emails, phone numbers, SSNs, Luhn-verified credit cards, IBANs, IP addresses) and credentials/secrets (API keys, JWTs, private keys, database URLs, Bearer tokens) locally from text or files (TXT, MD, CSV, JSON, LOG, ENV, DOCX). Runs 100% offline with zero network access and no API keys.

Scans and redacts personal data (PII) and credentials/secrets locally from text or files — completely offline (net: false, no API keys) — before sharing documents or sending them to an AI model.

How it works

  1. Scans inline text or a file (.txt, .md, .csv, .json, .log, .env, .xml, .html, .yaml, .docx).
  2. Detects PII and secrets across 11 categories:
    • PII: email, phone, ssn, credit_card (Luhn checksum verified), iban (ISO 7064 mod-97 verified), ip (IPv4 & IPv6)
    • Secrets: api_key (AWS, GitHub, OpenAI, Anthropic, OpenRouter, Stripe, Slack, Google, SendGrid, Resend, npm, PyPI), jwt, private_key (PEM blocks), connection_string (database/SMTP URLs with passwords), secret_assignment (Bearer tokens & KEY=secret assignments)
    • Plus optional customTerms (client names, internal codenames) and an allowlist.
  3. In redact mode (default), replaces every match consistently using:
    • placeholder (default): [EMAIL_1], [CREDIT_CARD_1] — the same value gets the same tag across the document so relationships stay readable.
    • mask: partial masking like j***@example.com or ****-****-****-4242.
    • hash: deterministic short SHA-256 tag like [EMAIL:a1b2c3d4].
  4. For .docx files, redacts text in place while keeping the Word document's formatting and structure.

Example

{
  "text": "Contact Jane at [email protected] or +1-415-555-0192. Key: sk-proj-abc12345678901234567890",
  "style": "placeholder"
}

Notes

  • Runs 100% offline (net: false, zero environment variables).
  • Finding previews are always masked so raw secrets are never echoed back in audit summaries.
  • Maximum file size: 25 MB.

Input

Validated before the workflow runs.

  • filefile

    File to scan or redact (TXT, MD, CSV, JSON, LOG, ENV, YAML, DOCX)

  • mode"redact" | "scan"

    redact (default) outputs sanitized text/file; scan only audits findings

  • textstring

    Text to scan or redact inline

    max length 500000

  • style"placeholder" | "mask" | "hash"

    How to replace matches: placeholder ([EMAIL_1], default), mask (j***@acme.com), or hash ([EMAIL:a1b2c3d4])

  • allowliststring[]

    Exact values to leave untouched, e.g. [email protected]

    max items 100

  • categories"private_key" | "connection_string" | "jwt" | "api_key" | "secret_assignment" | "email" | "credit_card" | "iban" | "ssn" | "phone" | "ip"[]

    Limit detection to specific categories; all categories enabled by default

    min items 1

  • customTermsstring[]

    Extra names, companies or codenames to redact (case-insensitive)

    max items 100

JSON Schema
{
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "description": "File to scan or redact (TXT, MD, CSV, JSON, LOG, ENV, YAML, DOCX)",
      "x-toolpal-file": true
    },
    "mode": {
      "anyOf": [
        {
          "type": "string",
          "const": "redact"
        },
        {
          "type": "string",
          "const": "scan"
        }
      ],
      "description": "redact (default) outputs sanitized text/file; scan only audits findings"
    },
    "text": {
      "type": "string",
      "maxLength": 500000,
      "description": "Text to scan or redact inline"
    },
    "style": {
      "anyOf": [
        {
          "type": "string",
          "const": "placeholder"
        },
        {
          "type": "string",
          "const": "mask"
        },
        {
          "type": "string",
          "const": "hash"
        }
      ],
      "description": "How to replace matches: placeholder ([EMAIL_1], default), mask (j***@acme.com), or hash ([EMAIL:a1b2c3d4])"
    },
    "allowlist": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 200,
        "minLength": 1
      },
      "maxItems": 100,
      "description": "Exact values to leave untouched, e.g. [email protected]"
    },
    "categories": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "const": "private_key"
          },
          {
            "type": "string",
            "const": "connection_string"
          },
          {
            "type": "string",
            "const": "jwt"
          },
          {
            "type": "string",
            "const": "api_key"
          },
          {
            "type": "string",
            "const": "secret_assignment"
          },
          {
            "type": "string",
            "const": "email"
          },
          {
            "type": "string",
            "const": "credit_card"
          },
          {
            "type": "string",
            "const": "iban"
          },
          {
            "type": "string",
            "const": "ssn"
          },
          {
            "type": "string",
            "const": "phone"
          },
          {
            "type": "string",
            "const": "ip"
          }
        ]
      },
      "minItems": 1,
      "description": "Limit detection to specific categories; all categories enabled by default",
      "uniqueItems": true
    },
    "customTerms": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 120,
        "minLength": 2
      },
      "maxItems": 100,
      "description": "Extra names, companies or codenames to redact (case-insensitive)"
    }
  }
}

Output

Validated before your agent receives it.

  • filefile

    Redacted output file (for file input)

  • moderequiredstring
  • textstring

    Redacted text (for inline text input)

  • byTyperequiredobject
  • findingsrequiredobject[]
  • findingsCountrequiredinteger
JSON Schema
{
  "type": "object",
  "required": [
    "mode",
    "findingsCount",
    "byType",
    "findings"
  ],
  "properties": {
    "file": {
      "type": "string",
      "description": "Redacted output file (for file input)",
      "x-toolpal-file": true
    },
    "mode": {
      "type": "string"
    },
    "text": {
      "type": "string",
      "description": "Redacted text (for inline text input)"
    },
    "byType": {
      "type": "object",
      "patternProperties": {
        "^.*$": {
          "type": "integer"
        }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type",
          "line",
          "preview",
          "replacement"
        ],
        "properties": {
          "line": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          },
          "preview": {
            "type": "string",
            "description": "Masked preview — raw secret is never returned"
          },
          "replacement": {
            "type": "string"
          }
        }
      }
    },
    "findingsCount": {
      "type": "integer"
    }
  }
}