A powerful obfuscator for JavaScript and Node.js
A powerful obfuscator for JavaScript and Node.js
Obfuscator.io adds VM-based bytecode obfuscation to this package - your JavaScript functions are compiled to custom bytecode that runs on an embedded virtual machine. Each build produces unique opcodes and VM structure, making reverse engineering and automated deobfuscation dramatically harder.
| Protection goal | Free (this package) | obfuscator.io |
|---|---|---|
| Rename identifiers | ✅ variable/function renaming | ✅ + VM-local symbols never exposed as JavaScript |
| Obscure strings | ✅ string array + base64/rc4 | ✅ + strings embedded in bytecode constants |
| Obscure control flow | ✅ control flow flattening | ✅ full bytecode virtualization, vmJumpsEncoding (runtime-computed jump targets), vmDeadCodeInjection (fake bytecode sequences) |
| Resist decompilation | ⚠️ output is still JavaScript | ✅ custom opcodes, vmStatefulOpcodes (position-dependent opcode mapping), vmMacroOps (fused instructions), vmDecoyOpcodes (fake opcode handlers) |
| Resist automated LLM-based analysis | ❌ fully vulnerable (no LLM-specific defenses) | ✅ bytecode encryption + anti-LLM defenses in vmSelfDefending and vmDebugProtection |
| Encryption | ✅ stringArrayEncoding (base64/rc4 on extracted strings) |
✅ vmBytecodeEncoding (per-instruction encoding), vmBytecodeArrayEncoding (whole bytecode array as single block) |
| Anti-debugging | ✅ debugProtection (freezes browser DevTools) |
✅ vmDebugProtection (multi-layered anti-debugging and anti-analysis defenses) |
| Tamper detection | ✅ selfDefending (breaks if beautified) |
✅ vmSelfDefending (multi-layered tamper detection, anti-hooking, anti-reverse-engineering protection) |
| Runs offline, no network | ✅ | ❌ uses obfuscator.io API (requires token) |
Visit Obfuscator.io · Pro API methods
This package provides access to Obfuscator.io API via CLI and Node.js API.
JavaScript Obfuscator has reached over 1 million npm downloads per week. I am currently preparing an EB-1 immigration case and collecting independent evidence of the project’s real-world professional usage and impact.
If you use JavaScript Obfuscator in a company project — especially at a well-known company, large organization, or widely used product — I would be very grateful if you could contact me.
Helpful evidence may include a brief confirmation or, ideally, a 1–2 page reference letter describing:
I can provide a simple draft/template to make this easy.
Please contact me at: [email protected]
Thank you for supporting the project.
JavaScript Obfuscator is a powerful free obfuscator for JavaScript, containing a variety of features which provide protection for your source code.
Key features:
The example of obfuscated code: github.com
It is not recommended to obfuscate vendor scripts and polyfills, since the obfuscated code is 15-80% slower (depends on options) and the files are significantly larger.
Install the package with Yarn or NPM and add it to your dependencies or devDependencies:
$ yarn add --dev javascript-obfuscatoror
$ npm install --save-dev javascript-obfuscatorFrom CDN:
<script src="https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js"></script>From node_modules:
<script src="./node_modules/javascript-obfuscator/dist/index.browser.js"></script>…obfuscate(sourceCode, options)Returns ObfuscationResult object which contains two public methods:
getObfuscatedCode() - returns string with obfuscated code;getSourceMap() - if sourceMap option is enabled - returns string with source map or an empty string if sourceMapMode option is set as inline;getIdentifierNamesCache() - returns object with identifier names cache if identifierNamesCache option is enabled, null overwise.Calling toString() for ObfuscationResult object will return string with obfuscated code.
Method takes two parameters, sourceCode and options – the source code and the options respectively:
sourceCode (string, default: null) – any valid source code, passed as a string;options (Object, default: null) – an object with options.For available options, see options.
obfuscateMultiple(sourceCodesObject, options)Accepts sourceCodesObject that is a map which keys are identifiers of source codes and values are source codes:
{
foo: 'var foo = 1;',
bar: 'var bar = 2;'
}Returns a map object which keys are identifiers of source codes and values are ObfuscationResult objects.
getOptionsByPreset(optionsPreset)Returns an options object for the passed options preset name.
The Pro API methods provide access to VM-based bytecode obfuscation through the obfuscator.io cloud service. VM obfuscation is the most advanced and secure form of code protection available, transforming your JavaScript functions into custom bytecode that runs on an embedded virtual machine.
Why VM Obfuscation?
To use Pro API methods, you need a valid API token from obfuscator.io:
obfuscatePro(sourceCode, options, proApiConfig, onProgress?) :new:Async method that obfuscates code using the Pro API with VM-based bytecode obfuscation.
const JavaScriptObfuscator = require('javascript-obfuscator');
const result = await JavaScriptObfuscator.obfuscatePro(
`function hello() { console.log("Hello World"); }`,
{
vmObfuscation: true, // Required!
compact: true
},
{
apiToken: 'your_javascript_obfuscator_pro_api_token'
}
);
console.log(result.getObfuscatedCode());Parameters:
sourceCode (string) – source code to obfuscateoptions (Object) – obfuscation options. To use the Pro API, include at least one Pro feature: vmObfuscation: true or parseHtml: true. When no Pro feature is enabled, obfuscatePro falls back to the basic (local) obfuscation API.apiConfig (Object) – Pro API configuration:apiToken (string, required) – your API token from obfuscator.iotimeout (number, optional) – request timeout in ms (default: 300000 - 5 minutes)version (string, optional) – Obfuscator.io version to use (e.g., '5.0.3'). Defaults to latest version if not specified.onProgress (function, optional) – callback for progress updates during obfuscationReturns: Promise<ObfuscationResult>
Note: When no Pro feature (
vmObfuscationorparseHtml) is enabled, the Pro API is not needed, soobfuscateProfalls back to the basic (local) obfuscation API and no API request is made.
Throws: ApiError if:
You can specify which obfuscator version to use via the version option:
const result = await JavaScriptObfuscator.obfuscatePro(
sourceCode,
{
vmObfuscation: true
},
{
apiToken: 'your_javascript_obfuscator_pro_api_token',
version: '5.0.3' // Use specific version
}
);The API uses streaming mode to provide real-time progress updates during obfuscation:
const result = await JavaScriptObfuscator.obfuscatePro(
sourceCode,
{Would you welcome a tested alias migration from source-map-resolve?
Allow domainLockRedirectUrl to accept empty string
Add a -silent or -quiet option to suppress logs
[Bug]: Duplicated names of class and functions in its static block
License control system
Consider Adopting NPM Trusted Publishing
how to not convert numbers into hexadecimal?
NestJS couldn't log some class names
Chrome Extension Manifest v3 Service Worker
[Improvement] Numbers to expressions improvement