
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
Anonymize values in an object based on property name patterns.
npm install anonymize
Let's say you want to anonymize the environment variables so that passwords, tokens and other secrets are not exposed, in effect turning this:
{
AWS_S3_KEY: 'BF73GVD903GFKSHFU2FJ',
AWS_S3_SECRET: 'f6+ddWfgd2&dfbs3/dfgj&jkdbcds1234dsfgsss',
DB_PASSWORD: 'FT^&*UHGFDRTYUJHVG',
NODE_ENV: 'production'
}
Into this:
{
AWS_S3_KEY: 'BF73GVD903GFKSHFU2FJ',
AWS_S3_SECRET: '******',
DB_PASSWORD: '******',
NODE_ENV: 'production'
}
You would simply:
var anonymize = require('anonymize')();
var anonEnv = anonymize(process.env);
You can control both the patterns used to match the properties and the replacement values.
By default properties containing the words secret, pass, auth or
token have their values replaced with ****** The default patterns
are case insensitive.
Both the patterns and the replacement value can be individually overridden by initializing the module with either an array of patterns or a replacement string (or an options hash containing both an array of patterns and a replacement value).
Create an anonymizer that replaces the value of any property whos name
either contains foo or bar:
// ['foo', 'bar'] is equivalent to [/foo/i, /bar/i]
var anonymize = require('anonymize')(['foo', 'bar']);
Create an anonymizer that replaces any property value with the string
hidden:
var anonymize = require('anonymize')('hidden');
Combine both custom patterns and a custom replacement string:
var anonymize = require('anonymize')({
patterns: ['foo', 'bar'],
replace: 'hidden'
});
If the replacement value is undefined, the property will be deleted
instead of having its value replaced.
If you instead of a string for the replacement use a function, you can control how a value is overwritten by conditionally returning the value that should be used for overwriting.
var anonymize = require('anonymize')({
replace: function (key, val) {
if (typeof val === 'number') return 0;
return 'hidden';
}
});
Yes, anonymize will also work on nested objects. So:
{
foo: { password: 'secret' },
bar: [ { token: 'secret' }]
}
Will be correctly anonymized to:
{
foo: { password: '******' },
bar: [ { token: '******' } ]
}
MIT
FAQs
Anonymize values in a list based on key name patterns
The npm package anonymize receives a total of 612 weekly downloads. As such, anonymize popularity was classified as not popular.
We found that anonymize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.