Scrub PII from Database Dumps Before Sharing

Remove emails, SSNs, IBANs, and card numbers from SQL exports and database dumps before sharing with developers or AI tools. Local processing only.

ZERO UPLOAD · ALL LOCAL
  1. Paste your original prompt or code into the input box - detections appear instantly in the Variables section.
  2. Review the detected items in the Variables JSON and the Scrubbed Output textarea with safe placeholders like [IP_1].
  3. Use the Download Variables buttons to save the mapping as JSON or CSV for later restoration.
  4. Copy the scrubbed text and paste it into your AI tool.
  5. Switch to the Restore tab, paste the AI response, upload your variables file, and the restoration happens automatically.

Worked examples for this use case

SQL INSERT with user records

Before
INSERT INTO users (id, email, phone) VALUES (1, '[email protected]', '+14155550101'), (2, '[email protected]', '(312) 555-0188');
After
INSERT INTO users (id, email, phone) VALUES (1, '[EMAIL_1]', '[PHONE_1]'), (2, '[EMAIL_2]', '[PHONE_2]');

SQL syntax and non-PII values (id column) are preserved. The scrubbed INSERT is valid SQL that can be imported directly.

MongoDB document export with payment data

Before
{"_id": "u001", "email": "[email protected]", "card": "4111111111111111", "iban": "GB29NWBK60161331926819"}
After
{"_id": "u001", "email": "[EMAIL_1]", "card": "[CC_1]", "iban": "[IBAN_1]"}

ORIGINAL PROMPT

SCRUBBED OUTPUT

VARIABLES

Scrub PII from Database Dumps Before Sharing

A database dump is a full copy of your production data. pg_dump, mysqldump, and mongodump output files contain every row of every table, including all the PII your application has ever stored. Sharing a database dump for debugging, developer onboarding, or vendor analysis is one of the highest-risk data operations a team can perform.1

Scrubbing a database dump before sharing is a practical way to reduce that risk without rebuilding your development database infrastructure. Paste the relevant tables or query results into the scrubber to replace PII with tokens, then share the anonymized version with the recipient who needs the data structure, not the real values.

PII in database exports

User tables contain the densest concentration of PII: email addresses, phone numbers, hashed or plaintext passwords, addresses, and date-of-birth fields. Order tables add credit card references, shipping addresses, and transaction IDs. For SaaS applications, subscription tables contain billing email addresses and payment method references. Consequently, a partial dump of just the users and orders tables from a mid-sized application can contain millions of identifiable records. Scrubbing the key fields before sharing reduces this to structural data that developers need for schema analysis or query debugging.

You should treat every database dump as a high-risk data artifact, regardless of which tables it contains. Even a dump of what appears to be a configuration or lookup table may contain admin email addresses, API keys stored as configuration values, or internal hostnames in endpoint URLs. The scrubber detects all 22 PII patterns in SQL text, including values inside quoted strings, comments, and stored procedure definitions. Before sharing any dump, scrub the PII-heavy tables and spot-check the remaining tables for embedded identifiers.2

How to scrub a SQL dump effectively

For a pg_dump or mysqldump output, focus on the INSERT INTO statements for PII-heavy tables: typically users, customers, orders, payments, and session tables. Copy those blocks into the scrubber separately. Email addresses, phone numbers, credit card patterns, SSNs, and IBANs are detected in SQL value lists. Building on this, IPv4 addresses and JWT tokens in session or auth tables are also caught. The scrubber processes quoted SQL strings correctly, with tokens replacing only the values inside quotes and the SQL syntax left intact.

You can scrub multiple related tables in the same browser session to preserve referential integrity. If the same email address appears in both the users table and the orders table, scrubbing them together in one session ensures both occurrences receive the same token. This means foreign key relationships survive the scrubbing process: a JOIN between the scrubbed users table and the scrubbed orders table produces correct results because [EMAIL_1] in the users table matches [EMAIL_1] in the orders table. Scrub all related tables in a single session rather than one at a time.3

Using a scrubbed dump for development

A common pattern is to scrub the PII fields and then share the cleaned dump with developers as a development seed database. Developers get a realistic data structure with correct table shapes, real row counts, and real relationship patterns, all without accessing any production PII. Yet the tokens are stable identifiers: [EMAIL_1] is always the same customer across every table it appears in, because the scrubber assigns a token to the unique value, not the occurrence. Referential integrity is preserved across tables for the same input.

You should validate the scrubbed dump before importing it into a development database. Run the scrubbed SQL against a test instance and verify that the row counts match the original, that foreign key constraints are satisfied, and that the schema DDL was not accidentally modified. The scrubber only touches quoted string values, so CREATE TABLE statements, indexes, and constraints pass through unchanged. A quick smoke test of the most common queries your application runs against the development database confirms that the scrubbed data behaves like the original from a query perspective.4

Prioritizing tables for scrubbing by PII density

Not every table in a database dump carries the same PII risk. Users, customers, contacts, orders, payments, and session tables hold the highest density of identifiable data and should always be scrubbed before sharing. Configuration tables, product catalog tables, and schema migration history tables typically contain no PII and do not require scrubbing. Schema DDL (CREATE TABLE and ALTER TABLE statements) contains column names and types but no data values, and is safe to share without scrubbing.

For a targeted partial dump shared for debugging purposes, target five tables, not the whole dump, copying only the INSERT blocks from your highest-risk tables and scrubbing those blocks specifically. Scrubbing INSERT blocks from five tables (users, customers, orders, payments, sessions) typically removes 90% or more of the PII exposure in a partial application database dump. The schema DDL and configuration tables can be shared separately without scrubbing, keeping the total volume of text you run through the scrubber manageable.

Query results versus full table exports

Single-query result exports (rows returned from a SELECT statement) often contain a subset of columns rather than the full table schema. Before scrubbing, identify which columns in the query result contain PII: email, phone, ssn, iban, ip_address, and token columns are the primary targets. The scrubber detects by value pattern rather than column name, so any PII-formatted value in any column is caught regardless of the column name used in your schema.

MongoDB and NoSQL document exports

MongoDB mongoexport produces NDJSON output: one document per line, with the full document structure as a JSON object. A user collection exported with mongoexport using the collection=users and out=users.ndjson flags generates one line per user document, each containing all the fields in that document. Email addresses, phone numbers, addresses, and account identifiers appear as JSON field values across every line in the export.

Paste the full mongoexport output into the scrubber. The pattern matching runs across every line simultaneously, tokenizing all PII field values in all documents in a single pass. The output is valid NDJSON with tokens replacing sensitive values, preserving the document structure and non-PII fields that developers need for schema analysis and query debugging. Import the scrubbed NDJSON into a development MongoDB instance using mongoimport with the collection flag for a fully functional development dataset with no production PII.5

Firestore, DynamoDB, and other document database exports

Firestore exports via gcloud firestore export produce a proprietary binary format that must be converted to JSON before scrubbing. Use the Firebase Admin SDK or community export tools to extract documents as JSON before passing them through the scrubber. DynamoDB exports via aws dynamodb scan with output set to json produce a JSON array of item objects; paste the JSON directly into the scrubber. The scrubber handles any JSON document format regardless of the underlying database that produced it.6

Development seed databases and PII propagation risk

Development and staging environments seeded from production dumps create long-lived copies of production PII that persist beyond the original sharing event. Developer workstations, local Docker containers, and shared development databases often have weaker access controls than production, widening the PII surface to everyone with development environment access. A single unscrubbed production dump seeded across ten developer machines creates ten independent copies of production customer data under ten different access control configurations.

Scrubbing the dump before seeding the development database eliminates PII from the development environment at the source. Developers receive a realistic data structure: correct table shapes, real row counts, real relationship patterns, and consistent foreign key references. The tokens serve as stable identifiers across tables for the session that produced them, so JOIN operations between scrubbed users and scrubbed orders tables work correctly in the development database. This approach reduces the regulatory classification of the development database to non-regulated status, removing it from the scope of PII-related compliance audits.

Automating scrubbing in the production-to-dev data pipeline

For teams that refresh development environments regularly from production snapshots, integrate the scrubbing step into the data pipeline rather than performing it manually each time. A pipeline stage that exports the target tables, scrubs the exported text, and imports the scrubbed data into the development database makes PII-free seeding automatic and consistent. The variables file produced by each pipeline run provides an audit record of what was replaced in each refresh cycle.

Wiring the scrub step into the pipeline means every refresh produces a development database with no production PII, by construction. CapyToolkit runs the scrubber locally in your browser, so the pipeline stage can call it without uploading dumps to a server, and the per-run variables file gives auditors a clear record of what was replaced in each cycle.

When to use this

Use this before sharing any table export, query result, or database dump with a developer, vendor, analytics team, or AI tool when the output contains customer or employee records.

Examples

SQL INSERT with user records

Before
INSERT INTO users (id, email, phone) VALUES (1, '[email protected]', '+14155550101'), (2, '[email protected]', '(312) 555-0188');
After
INSERT INTO users (id, email, phone) VALUES (1, '[EMAIL_1]', '[PHONE_1]'), (2, '[EMAIL_2]', '[PHONE_2]');

SQL syntax and non-PII values (id column) are preserved. The scrubbed INSERT is valid SQL that can be imported directly.

MongoDB document export with payment data

Before
{"_id": "u001", "email": "[email protected]", "card": "4111111111111111", "iban": "GB29NWBK60161331926819"}
After
{"_id": "u001", "email": "[EMAIL_1]", "card": "[CC_1]", "iban": "[IBAN_1]"}
Sources
  1. 1.

    PostgreSQL, "pg_dump," postgresql.org, accessed June 2026. https://www.postgresql.org/docs/current/app-pgdump.html

  2. 2.

    Microsoft, "Supported entities," microsoft.github.io, accessed June 2026. https://microsoft.github.io/presidio/supported_entities/

  3. 3.

    M. Jones, et al., "JSON Web Token (JWT)," RFC 7519, IETF, May 2015. https://www.rfc-editor.org/rfc/rfc7519.html

  4. 4.

    Morris Dworkin, "Recommendation for Block Cipher Modes of Operation: Methods for Format-Preserving Encryption," SP 800-38G, nist.gov, March 2016. https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38G.pdf

  5. 5.

    MongoDB, "mongoexport," mongodb.com, accessed June 2026. https://www.mongodb.com/docs/database-tools/mongoexport/

  6. 6.

    Amazon Web Services, "scan," docs.aws.amazon.com, accessed June 2026. https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html

FAQ