# PII Redactor for GDPR & LLM Pipelines (`praised_tumbler/pii-redactor-eu-gdpr`) Actor

Detect, mask or anonymize emails, phones, IBANs, cards, national ID numbers of 22 countries (PESEL, CNP, codice fiscale, DNI, EGN, Steuer-ID, SSN) and API secrets in text, PDF and DOCX. Checksum-validated, no external API.

- **URL**: https://apify.com/praised_tumbler/pii-redactor-eu-gdpr.md
- **Developed by:** [Maine Wayne](https://apify.com/praised_tumbler) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 item redacteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PII Redactor for GDPR & LLM Pipelines (EU national IDs, IBAN, secrets)

Find and mask **personal data (PII) and secrets** in text, PDF and DOCX before you share a document, store it, or send it to an LLM. Three modes cover the usual needs: numbered placeholders that can be mapped back (pseudonymisation), data masking with blocks, or removal. The Actor runs **inside Apify**: no external AI or redaction API, no API key, and nothing is sent to a third party.

Unlike simple regex masks, identifiers with a check digit are **validated**, so random numbers are mostly left alone: a 10-digit order number is not mistaken for a Bulgarian personal number (EGN), an 11-digit one must pass the Polish PESEL or another national rule, and a long number is not masked as a card unless it passes the Luhn check.

### What it detects

| Type | How it is recognised |
|---|---|
| `EMAIL` | E-mail addresses |
| `PHONE` | International numbers (`+359 888 123 456`, `00359...`) and Bulgarian national formats (`0888 123 456`, `02 987 6543`) |
| `IBAN` | Any IBAN of 80+ countries: length per country and the ISO 13616 mod-97 checksum must be valid |
| `PAYMENT_CARD` | 13 to 19 digit card numbers that pass the Luhn check |
| `BG_EGN` | Bulgarian personal number (EGN): valid birth date (all three century encodings) and valid check digit |
| `NATIONAL_ID` | Personal identification numbers of 22 countries, each checked against its own rule (check digit, check letter or embedded birth date): **PL** PESEL, **RO** CNP, **IT** codice fiscale, **ES** DNI/NIE, **FR** NIR, **DE** Steuer-ID, **SE** personnummer, **FI** henkilötunnus, **BE** national number, **CZ/SK** rodné číslo, **GR** AMKA, **EE/LT** personal code, **LV** personas kods, **UK** National Insurance number, **US** SSN. Numbers with a weak check are only taken next to their label: **NL** BSN, **PT** NIF, **HR** OIB, **AT** SVNR, **IE** PPS number, **BG** LNCh. With `includeDetails` each finding names its scheme (`subtype`, for example `PL_PESEL`) |
| `EU_VAT` | EU VAT numbers (format per country; Bulgarian numbers checksum-validated). Off by default |
| `IP_ADDRESS` | IPv4 and IPv6 addresses |
| `SECRET` | AWS access keys, GitHub and Slack tokens, Google API keys, `sk-` style keys, Stripe secret keys (`sk_live_`, `rk_live_`, `whsec_`), JWTs, private key blocks |
| custom terms | Any words or phrases you list (names, project code names), case-insensitive |

**Names are not detected automatically.** The Actor does not use a name-recognition model. Add the names you know to `customTerms`, or review the output before relying on it.

### Input

| Field | Description |
|---|---|
| `texts` | Plain texts (up to 100, each up to 1,000,000 characters). |
| `urls` | Public links to PDF, DOCX, HTML or text files (up to 50). robots.txt is respected (also after redirects). PDFs need a text layer. Older encodings such as windows-1251 are read correctly. |
| `inlineDocuments` | Small files as base64 (`[{"filename": "a.pdf", "contentBase64": "..."}]`). |
| `entities` | Which types to redact (see above). |
| `customTerms` | Extra exact terms to redact. |
| `mode` | `placeholder` (`[EMAIL_1]`, same value = same placeholder), `mask`, or `remove`. |
| `includeDetails` | Add positions of findings (without original values). |
| `includeOriginalValues` | Add a `mapping` placeholder to original, to restore text after an LLM step. This puts the personal data back into your dataset. |

#### Example

Input:

```json
{ "texts": ["Contact Ivan Petrov at ivan.petrov@example.com or +359 888 123 456. IBAN BG80 BNBG 9661 1020 3456 78."], "customTerms": ["Ivan Petrov"] }
```

Output item:

```json
{
    "source": "text #1",
    "status": "ok",
    "totalFindings": 4,
    "findings": { "EMAIL": 1, "PHONE": 1, "IBAN": 1, "CUSTOM": 1 },
    "redactedText": "Contact [CUSTOM_1] at [EMAIL_1] or [PHONE_1]. IBAN [IBAN_1]."
}
```

### Ready-made examples

Saved examples you can open, run and copy:

- [Redact personal data before sending text to an LLM](https://apify.com/praised_tumbler/pii-redactor-eu-gdpr/examples/redact-pii-before-sending-text-to-llm)
- [Mask Bulgarian EGN, IBAN and phone numbers](https://apify.com/praised_tumbler/pii-redactor-eu-gdpr/examples/mask-bulgarian-egn-iban-phone-in-text)

### Pricing

Pay per event: a small fee per **item** processed (`item-redacted`) plus a small fee per **page unit** (`page-processed`: one PDF page, or about 3,000 characters). Failed items are free. Set **Max cost per run** to cap spending; the Actor never processes or charges more than your limit allows. See the pricing panel for current prices.

### Limits and honest notes

- Rule-based detection: it finds well-defined identifiers, not everything that is personal. Names, addresses, free-text descriptions, dates of birth and other context are **not** detected unless you list them. Always review output that must be compliant.
- National ID numbers are recognised by their format and check rule, not by context. A random number of the same length can pass a check by chance (measured: about 3% of random 11-digit numbers and 0.2% of random 13-digit numbers; none of 9 or 10 digits), so an order number is occasionally masked too. Switch `NATIONAL_ID` off in `entities` if that matters more to you than missing one.
- Phone detection is pattern-based. A phone-like number can be missed or, rarely, a long number masked; check important documents.
- PDFs must have a text layer; scanned PDFs need OCR first (run [PDF & DOCX to Markdown](https://apify.com/praised_tumbler/pdf-docx-to-markdown), then pass the text here).
- This is a tool, not legal advice, and no guarantee of GDPR compliance.
- The Actor processes the personal data you give it only to redact it; results are stored in your own dataset (default retention applies).

### FAQ

**Is my data sent to another service?** No. All detection runs inside the Actor.

**Can I get the original values back?** Yes, switch on `includeOriginalValues` with placeholder mode; you get a mapping to restore the text after an LLM step. Without it the originals are not returned.

**Why is my 10-digit number not redacted as EGN?** Because it is not a valid EGN (birth date and check digit must match). That is intentional.

**Which countries' ID numbers are covered?** Bulgaria (EGN, own type `BG_EGN`) plus Poland, Romania, Italy, Spain, France, Germany, Sweden, Finland, Belgium, Czechia, Slovakia, Greece, Estonia, Lithuania, Latvia, the Netherlands, Portugal, Croatia, Austria, Ireland, the UK and the US under `NATIONAL_ID`. Danish CPR numbers are not covered (they have no check digit and look like many other numbers).

**Does it work with Bulgarian?** Yes: Cyrillic text, EGN, Bulgarian phone formats and BG IBANs are supported.

**Can an AI agent call it?** Yes, via the Apify API or MCP server; send `texts` and use the `redactedText` field.

### Related Actors

- [PDF & DOCX to Markdown](https://apify.com/praised_tumbler/pdf-docx-to-markdown): PDF, DOCX and HTML to Markdown, with OCR for scanned pages.
- [Image OCR](https://apify.com/praised_tumbler/image-ocr-bulgarian-cyrillic): text from images and photos.
- [Excel, PowerPoint & CSV to Markdown / JSON](https://apify.com/praised_tumbler/excel-powerpoint-to-markdown-json): spreadsheets and slide decks for LLMs.

# Actor input Schema

## `texts` (type: `array`):

Plain texts to redact (up to 100 texts of 1,000,000 characters).

## `urls` (type: `array`):

Public http(s) links to PDF, DOCX, HTML or text files (up to 50). robots.txt is respected. PDFs need a text layer.

## `inlineDocuments` (type: `array`):

Small files passed directly, e.g. \[{"filename": "a.pdf", "contentBase64": "JVBERi0..."}]. Maximum 20 files and 8 MB in total.

## `entities` (type: `array`):

Types of personal data and secrets to find. EU VAT numbers are off by default because company VAT numbers are usually public business data.

## `customTerms` (type: `array`):

Exact words or phrases to mask wherever they appear, case-insensitive. Use this for names, because the Actor does not detect names automatically.

## `mode` (type: `string`):

placeholder = \[EMAIL_1] (the same value always gets the same placeholder), mask = block characters, remove = delete.

## `includeDetails` (type: `boolean`):

Adds a `details` list (type, start, end, replacement) without the original values.

## `includeOriginalValues` (type: `boolean`):

Adds a `mapping` of placeholder to the original value so the text can be restored after an LLM step. This puts the personal data back into your dataset: use with care. Needs placeholder mode.

## `removeHeadersFooters` (type: `boolean`):

Drops lines that repeat at the top or bottom of most pages.

## `maxPagesPerDocument` (type: `integer`):

Only the first N pages of longer PDFs are processed (and billed).

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped with an error (not billed).

## Actor input object example

```json
{
  "texts": [
    "Contact Ivan Petrov at ivan.petrov@example.com or +359 888 123 456. Pay to IBAN BG80 BNBG 9661 1020 3456 78. Server 203.0.113.7."
  ],
  "urls": [],
  "inlineDocuments": [],
  "entities": [
    "EMAIL",
    "PHONE",
    "IBAN",
    "PAYMENT_CARD",
    "BG_EGN",
    "NATIONAL_ID",
    "IP_ADDRESS",
    "SECRET"
  ],
  "customTerms": [
    "Ivan Petrov"
  ],
  "mode": "placeholder",
  "includeDetails": false,
  "includeOriginalValues": false,
  "removeHeadersFooters": false,
  "maxPagesPerDocument": 200,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `results` (type: `string`):

All results of the run (JSON items of the default dataset).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "texts": [
        "Contact Ivan Petrov at ivan.petrov@example.com or +359 888 123 456. Pay to IBAN BG80 BNBG 9661 1020 3456 78. Server 203.0.113.7."
    ],
    "customTerms": [
        "Ivan Petrov"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("praised_tumbler/pii-redactor-eu-gdpr").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "texts": ["Contact Ivan Petrov at ivan.petrov@example.com or +359 888 123 456. Pay to IBAN BG80 BNBG 9661 1020 3456 78. Server 203.0.113.7."],
    "customTerms": ["Ivan Petrov"],
}

# Run the Actor and wait for it to finish
run = client.actor("praised_tumbler/pii-redactor-eu-gdpr").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "texts": [
    "Contact Ivan Petrov at ivan.petrov@example.com or +359 888 123 456. Pay to IBAN BG80 BNBG 9661 1020 3456 78. Server 203.0.113.7."
  ],
  "customTerms": [
    "Ivan Petrov"
  ]
}' |
apify call praised_tumbler/pii-redactor-eu-gdpr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,praised_tumbler/pii-redactor-eu-gdpr"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/N1dn6RlY8wSm3VHHR/builds/nTEmLjYyOnDzQAINS/openapi.json
