Skip to main content
This tutorial takes a JavaScript file, obfuscates it, and runs the generated file to confirm that its result did not change.
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 .mjs build 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.
Terminal
The generated program prints the same value as the input:
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
Run the script with your package manager after your compiler or bundler emits plain JavaScript.
webfuscator does not parse TypeScript or JSX and does not emit source maps. Compile syntax extensions first, then obfuscate the JavaScript output.

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.
Last modified on August 22, 2026