Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

javascript-obfuscator

> 安全
Open source

A powerful obfuscator for JavaScript and Node.js

16.2K stars0 likes18 views
WebsiteGitHub

About

A powerful obfuscator for JavaScript and Node.js

JavaScript obfuscator


:rocket: Obfuscator.io with VM Obfuscation

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.


Do you use JavaScript Obfuscator at your company?

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:

  • how your team or company used JavaScript Obfuscator;
  • why you chose it;
  • what problem it helped solve;
  • whether it was used in production or an important internal workflow;
  • your role and how you are familiar with the usage.

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:

  • VM bytecode obfuscation (via Obfuscator.io)
  • variables renaming
  • strings extraction and encryption
  • dead code injection
  • control flow flattening
  • various code transformations
  • and more...

The example of obfuscated code: github.com

Online version:

obfuscator.io

Plugins:

  • Webpack plugin: webpack-obfuscator
  • Webpack loader: obfuscator-loader
  • Esbuild plugin: esbuild-javascript-obfuscator
  • Gulp: gulp-javascript-obfuscator
  • Grunt: grunt-contrib-obfuscator
  • Rollup: rollup-plugin-javascript-obfuscator
  • Weex: weex-devtool
  • Malta: malta-js-obfuscator
  • Netlify plugin: netlify-plugin-js-obfuscator
  • Snowpack plugin: snowpack-javascript-obfuscator
  • Vite plugin: vite-plugin-bundle-obfuscator

NOTE! the README on the master branch might not match that of the latest stable release!

If you have a question, check this section first: FAQ

:warning: Important

Only obfuscate the code that belongs to you.

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.

Installation

Using Yarn or NPM

Install the package with Yarn or NPM and add it to your dependencies or devDependencies:

bash
$ yarn add --dev javascript-obfuscator

or

bash
$ npm install --save-dev javascript-obfuscator

In a Browser

From CDN:

xml
<script src="https://cdn.jsdelivr.net/npm/javascript-obfuscator/dist/index.browser.js"></script>

From node_modules:

xml
<script src="./node_modules/javascript-obfuscator/dist/index.browser.js"></script>

Usage

…

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.


:shield: Pro API Methods (VM Obfuscation)

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?

  • Strongest protection: Code is converted to bytecode that cannot be directly understood
  • Anti-decompilation: No standard JavaScript to reverse engineer
  • Customizable VM: Each obfuscation generates unique opcodes and VM structure
  • Layered security: Combine with other obfuscation options for defense in depth

Getting an API Token

To use Pro API methods, you need a valid API token from obfuscator.io:

  1. Create an account at obfuscator.io
  2. Subscribe to a Pro, Team, or Business plan that includes API access
  3. Generate your API token at obfuscator.io/dashboard

obfuscatePro(sourceCode, options, proApiConfig, onProgress?) :new:

Async method that obfuscates code using the Pro API with VM-based bytecode obfuscation.

javascript
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 obfuscate
  • options (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.io
    • timeout (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 obfuscation

Returns: Promise<ObfuscationResult>

Note: When no Pro feature (vmObfuscation or parseHtml) is enabled, the Pro API is not needed, so obfuscatePro falls back to the basic (local) obfuscation API and no API request is made.

Throws: ApiError if:

  • API token is invalid or expired
  • API request fails

Pro API with Specific Version

You can specify which obfuscator version to use via the version option:

javascript
const result = await JavaScriptObfuscator.obfuscatePro(
    sourceCode,
    {
        vmObfuscation: true
    },
    {
        apiToken: 'your_javascript_obfuscator_pro_api_token',
        version: '5.0.3'  // Use specific version
    }
);

Pro API with Progress Updates

The API uses streaming mode to provide real-time progress updates during obfuscation:

javascript
const result = await JavaScriptObfuscator.obfuscatePro(
    sourceCode,
    {

Issues· 23 open

View all issuesOpen on GitHub
  • #1446

    Would you welcome a tested alias migration from source-map-resolve?

    Updated Aug 27, 2026
  • #1217

    Allow domainLockRedirectUrl to accept empty string

    enhancementUpdated Jul 10, 2026
  • #1304

    Add a -silent or -quiet option to suppress logs

    enhancementUpdated May 22, 2026
  • #1128

    [Bug]: Duplicated names of class and functions in its static block

    bug3rd party libraryUpdated Mar 22, 2026
  • #1356

    License control system

    enhancementUpdated Dec 17, 2025
  • #1323

    Consider Adopting NPM Trusted Publishing

    Updated Oct 21, 2025
  • #1317

    how to not convert numbers into hexadecimal?

    Updated Aug 7, 2025
  • #1214

    NestJS couldn't log some class names

    Updated Apr 4, 2025
  • #1229

    Chrome Extension Manifest v3 Service Worker

    Updated Apr 15, 2024
  • #773

    [Improvement] Numbers to expressions improvement

    enhancementUpdated Aug 28, 2023

> Tags

TypeScriptbrowsercontrol-flowcryptographyencoding

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.