JS-Confuser: JavaScript Obfuscation Tool

2.0.1 · active · verified Wed Apr 22

JS-Confuser is an active JavaScript obfuscation tool designed to make code difficult to read and analyze, thereby protecting intellectual property and deterring reverse engineering. The current stable version is 2.0.1, which builds upon a significant 2.0.0 rewrite implemented with Babel, introducing a revamped API and enhanced obfuscation capabilities. The project maintains an active release cadence with frequent updates, bug fixes, and feature additions across minor and patch versions. Key differentiators include robust control flow obfuscation, advanced string concealing with randomized charsets, anti-tampering protection against runtime modifications, and anti-tooling measures designed to defeat common deobfuscators. It also offers features like variable renaming, function obfuscation, and integrity checks to detect unauthorized source code changes. The primary API, `obfuscate()`, is promise-based and returns an object containing the obfuscated code.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use the promise-based `obfuscate` function with a simple code snippet, showcasing a typical configuration and how to access the resulting obfuscated code from the resolved object.

import { obfuscate } from 'js-confuser';

const originalCode = `
  function calculateFibonacci(n) {
    let a = 0, b = 1, temp;
    for (let i = 2; i <= n; i++) {
      temp = a + b;
      a = b;
      b = temp;
    }
    return b;
  }

  const result = calculateFibonacci(10);
  console.log('Fibonacci(10):', result);
`;

obfuscate(originalCode, {
  target: 'browser', // Or 'node' depending on your target environment
  preset: 'high',     // Choose a preset like 'low', 'medium', 'high', 'extreme'
  stringEncoding: true,
  // es5: true,       // Uncomment if targeting older JavaScript environments
})
.then(result => {
  console.log('--- Obfuscated Code ---');
  console.log(result.code);
  // To execute the obfuscated code (use with caution, especially with untrusted code):
  // try {
  //   eval(result.code);
  // } catch (e) {
  //   console.error('Error executing obfuscated code:', e);
  // }
})
.catch(error => {
  console.error('Obfuscation failed:', error);
});

view raw JSON →