Redacts Javascript objects
Last updated 5 years ago by rueckstiess .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install objfuscate -g
SYNC missed versions from official npm registry.


build status

Redacts JSON object values recursively, and keys if desired.


npm install -g objfuscate


   objfuscate [options] <jsonfile>
   objfuscate --version
   objfuscate -h | --help

   -h, --help           Print this help screen
   -k, --include-keys   Obfuscate keys as well
   -p, --pretty         Print the result with line breaks and indentation

Use with a JSON file

objfuscate ./sensitive.json

This will write the obfuscated JSON to stdout. In most cases, you will want to store the result in another file, which you can do like so:

objfuscate ./sensitive.json > obfuscated.json

Note: The file can be a single JSON object, a newline-delimited list of JSON objects (for example when using mongoexport without the --jsonArray option) or an array of JSON objects (for example when using mongoexport with the --jsonArray option). The output format matches the input format.

Use with JSON string

objfuscate '{"my": "secret"}'

Note: The JSON string must be wrapped in single quotes and you need to write proper JSON, which includes double quotes around key names and strings.

Value Obfuscation

Currently, only the following values are replaced:

  • Strings
  • Numbers

Values use a cache so that each value is replaced with the same random value, which is created when a particular value is first encountered. This ensures that the dataset has the same cardinality as the original.

Key Obfuscation

To replace object keys as well, use the -k or --include-keys option like so:

objfuscate -k ./paranoid.json
objfuscate --include-keys ./paranoid.json

They key cache is the same as the value cache (see above). A key named "foo" is replaced with the same new string as the value "foo".

Pretty output

(Only applicable if the input file was a single JSON object, or an array of JSON objects. Newline-delimited JSON objects are not prettified.)

Per default, the output is written compressed into a single line without whitespace. If you want the output to be nicely formatted with line breaks, whitespace and indentations, use the -p or --pretty option.

objfuscate --pretty ./documents.json > pretty-obfuscated.json


Apache 2.0

Current Tags

  • 0.2.0                                ...           latest (5 years ago)

3 Versions

  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (8)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |