webfuscator exposes a JavaScript API, not a command-line interface. The build script below handles file reads and writes.Prerequisites
- Node.js
^22.18.0 || >=24.11.0 - An ESM project or an
.mjsbuild script
1
Install webfuscator
Add the package as a development dependency.
2
Create a JavaScript input
Save this program as
src/input.js.src/input.js
3
Create the build script
Save this script as
obfuscate.mjs. It reads the input, calls obfuscate, and writes the returned source.obfuscate.mjs
4
Build and run the result
Run the build script, then execute the generated JavaScript.The generated program prints the same value as the input:
Terminal
Output
You now have a repeatable obfuscation step. Running it again with the same input, options, package version, and Node.js version produces the same file.
Add it to your package scripts
package.json
Next steps
Configure transforms
Decide which removal, lowering, naming, and literal passes belong in your build.
Review every option
Check accepted types, defaults, and transform-specific configuration.