1. Home
  2. Tools
  3. JavaScript Obfuscator

JavaScript Obfuscator

Make your JavaScript hard to read before you ship it. It runs in your browser and your code is never uploaded.

Strength

Higher strength gives output that is harder to read but larger and slower to run.

Your code is processed in your browser and is not uploaded. The obfuscation library is downloaded from this site the first time you press Obfuscate.

How to use it

  1. Paste your JavaScript into the left box, or use Open file to load a .js file.
  2. Pick a strength: Low, Medium or High. You can then switch individual options on or off.
  3. Press Obfuscate. The first time, the tool loads the obfuscation library, which takes a moment.
  4. Use Copy or Download .js to take the result.
  5. Run the obfuscated file through your normal tests before you deploy it.

What the options do

  • Compact output puts the code on one line.
  • String array moves string literals into a lookup array and replaces them with calls that read from it.
  • Control flow flattening rewrites the structure of functions into a hard-to-follow switch loop. It makes the code larger and slower.
  • Dead code injection adds blocks of code that never matter, to bury the real logic. It makes the code larger.
  • Self defending makes the code break if someone reformats or beautifies it.
  • Rename globals also renames top-level variables and functions. Leave it off if other scripts, or your HTML, call them by name.
  • Identifier names chooses how variables and functions are renamed.

What obfuscation does, and what it does not

Obfuscation rewrites your code so that it still behaves the same but is much harder for a person to read. It discourages casual copying and makes quick inspection in browser developer tools less useful.

It is not encryption and it is not security. Code that runs in a visitor’s browser can always be read by a determined person, and automated tools can undo parts of obfuscation. Never put passwords, API keys or other secrets in JavaScript that ships to users, obfuscated or not. Keep them on the server. The guide to protecting your JavaScript code covers this in more detail.

Stronger settings cost something: larger files, slower start-up and, with some options, code that is harder to debug. Keep your original source, because you cannot recover it from the output.

Privacy

The obfuscation runs in a background worker inside your browser, using the open-source javascript-obfuscator library (version 5.11.0, BSD-2-Clause licence), which is served from this site. Your code is not sent to CodeROG or anyone else.

Related guides

Frequently asked questions

No. The code is processed in your browser, in a background worker. Only the library file itself is downloaded, from this site, the first time you press Obfuscate.

No. Obfuscated code still runs as it is, so the browser has to be able to read it, and so can anyone else. It makes the code harder to understand, but it does not hide it or keep it secret.

It is meant to. Obfuscation changes how the code is written, not what it does. Test the result anyway, especially with options such as rename globals, control flow flattening and self defending, which can affect code that relies on global names or on being formatted.

It can. Control flow flattening and dead code injection in particular make the output larger and slower to run. Start with Low or Medium and raise the strength only where you need it.

Not from this tool. Keep your original source files and obfuscate a copy for release.

The library found a syntax error in what you pasted, such as a missing bracket. The message gives the line and column where it stopped. This tool handles JavaScript only, not TypeScript or JSX, so compile those first.

Input is limited to 1,000,000 characters. For larger projects, obfuscate files one at a time or use the library in your own build.

Need a hand with this?

Let our engineers take it from here