npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@majilol/pg-anon

v0.1.0

Published

Export your postgreSQL database anonymized

Downloads

4

Readme

pg-anon

Fork of @rap2hpoutre pg-anonymizer library

Export your PostgreSQL database anonymized. Replace all sensitive data thanks to faker. Output to a file that you can easily import with psql.

Usage

Run this command by giving a connexion string or .sql file path and an output file name (no need to install first thanks to npx):

  npx pg-anon --input=postgres://user:secret@localhost:1234/mydb --faker-locale=ru -o backend-dump.sql --transformer=./scripts/anon-extensions.js --columns=public.users.name:extension.firstName,public.users.second_name:extension.lastName,public.users.third_name:extension.middleName,public.users.phone:extension.phone,public.users.email:extension.email
  npx pg-anon --input=./path-to.sql --faker-locale=ru -o backend-dump.sql --transformer=./scripts/anon-extensions.js --columns=public.users.name:extension.firstName,public.users.second_name:extension.lastName,public.users.third_name:extension.middleName,public.users.phone:extension.phone,public.users.email:extension.email

☝️ This command requires pg_dump. It may already be installed as soon as PostgreSQL is installed.

API

--input

Use --input option to specify path to .sql file or to specify the connection to psql database.

--columns | -c

You can choose which faker function you want to use to replace data (default is faker.random.word):

npx pg-anonymizer postgres://localhost/mydb \
  --columns=firstName:faker.name.firstName,lastName:faker.name.lastName

--extension

Use an extension file to create your own custom replacements

Create an extension file, written in javascript

// myExtension.js
module.exports = {
  maskEmail: (email) => {
   const [name, domain] = email.split('@');
   const { length: len } = name;
   const maskedName = name[0] + '...' + name[len - 1];
   const maskedEmail = maskedName + '@' + domain;
   return maskedEmail;
  }
};

Pass the path to --extension and use the module exports in --columns

npx pg-anonymizer postgres://localhost/mydb \
  --extension=./myExtension.js \
  --columns=email:extension.maskEmail

--skip

Skip tables

Use --skip to skip anonymizing entire tables

--preserve-null | -n

Preserve NULL values

Use --preserve-null to skip anonymization on fields with NULL values.

--faker-locale

Set fakers locale (i18n)

Use --faker-locale to change the locale used by faker (default: en)

Also supports pg_dump args when works with connection

  npx pg-anon [--lib-args] -- [pg_args]

Example

  npx pg-anon --input=./path-to.sql --faker-locale=ru -o backend-dump.sql --transformer=./scripts/anon-extensions.js --columns=public.users.name:extension.firstName,public.users.second_name:extension.lastName,public.users.third_name:extension.middleName,public.users.phone:extension.phone,public.users.email:extension.email