{"id":18660,"library":"pg-anonymizer","title":"pg-anonymizer","description":"pg-anonymizer is a CLI tool (built with oclif) that exports a PostgreSQL database and anonymizes sensitive columns using faker.js. It wraps pg_dump and replaces data on the fly. Current stable version 0.8.1, released Feb 2024, with ~5 releases per year. Key differentiators: no database installation, works as a pipe, supports custom faker functions, extension files, and config files. Alternative to pg_dump with custom scripts or postgresql_anonymizer, but simpler and portable.","status":"active","version":"0.8.1","language":"javascript","source_language":"en","source_url":"https://github.com/rap2hpoutre/pg-anonymizer","tags":["javascript","oclif","typescript"],"install":[{"cmd":"npm install pg-anonymizer","lang":"bash","label":"npm"},{"cmd":"yarn add pg-anonymizer","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-anonymizer","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required system tool for dumping the database; the CLI calls pg_dump internally.","package":"pg_dump","optional":false}],"imports":[{"note":"ESM and CJS both supported (dual package). The default export is the CLI runner.","wrong":"const pgAnonymizer = require('pg-anonymizer')","symbol":"default","correct":"import pgAnonymizer from 'pg-anonymizer'"},{"note":"Named export for programmatic usage; available since v0.6.","wrong":"const { anonymize } = require('pg-anonymizer')","symbol":"anonymize","correct":"import { anonymize } from 'pg-anonymizer'"},{"note":"TypeScript types are bundled; use import type for type-only imports.","wrong":"","symbol":"types","correct":"import type { Config } from 'pg-anonymizer'"}],"quickstart":{"code":"npx pg-anonymizer postgres://user:pass@localhost:5432/mydb --columns=email,firstName,lastName --output dump.sql","lang":"typescript","description":"Anonymize a PostgreSQL database export by specifying columns to anonymize, using npx without installation."},"warnings":[{"fix":"Install PostgreSQL client tools (e.g., apt-get install postgresql-client) or ensure pg_dump is in PATH.","message":"pg_dump must be installed separately; it is not bundled with npm package.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you relied on faker.random.word default, specify columns explicitly with ':faker.random.word'.","message":"v0.6.0 changed default faker from faker.random.word to auto-detection based on column name; custom --columns without faker function now auto-detects.","severity":"breaking","affected_versions":">=0.6.0 <0.7.0"},{"fix":"Use --skip to exclude tables from anonymization instead of prefixing column names.","message":"The --columns option with dot-notation for tables (e.g., public.user.email) may be deprecated in future; prefer using --skip for tables.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Always specify --columns to avoid accidentally anonymizing unintended columns.","message":"Unexpected anonymization of non-sensitive columns: if no --columns specified, a default list of columns (email, name, etc.) is anonymized, potentially including non-sensitive data.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use absolute paths for --output to avoid confusion.","message":"Output file path is relative to current working directory, not the script location.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to >=12.","message":"Node.js >=12 required; Node 10 support dropped in v0.6.0.","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install PostgreSQL client tools (e.g., on Ubuntu: sudo apt-get install postgresql-client).","cause":"pg_dump is not installed on the system.","error":"pg_dump: command not found"},{"fix":"Use dynamic import() or switch to ESM: 'import pgAnonymizer from \"pg-anonymizer\"'.","cause":"When using require in an older CJS project without transpilation, but package is ESM-only in some versions.","error":"Error: Cannot find module 'pg-anonymizer'"},{"fix":"Check the column name spelling and ensure it exists in the database.","cause":"Specified a column name that does not exist in any database table.","error":"Error: Column 'nonexistent' does not exist in any table"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}