JavaScript Obfuscator
Protect your source code by making it unreadable
Make your script harder to read at a glance
When you publish JavaScript, anyone can open it in the browser. Obfuscation does not make code secret, but it does raise the effort needed to skim it, copy it or spot where a value is defined. This tool wraps your code in an encoded form that still runs the same way, and it does it with two levels you can choose between.
How to obfuscate a script
- Paste your code into Clean Source, or press Load Sample to try a small login check.
- Choose an Obfuscation Level: Light (CharCode conversion) or Aggressive (Base64 Eval).
- Leave Mangle Variable Names ticked if you want names shortened first, or untick it to keep them.
- Click Obfuscate Now, then use Copy on the Obfuscated Code panel.
What the two levels produce
- Light converts every character of your script to its numeric code and outputs a single eval(String.fromCharCode(...)) call. It is compact and quick to run.
- Aggressive first Base64-encodes the code, wraps it in a decode-and-eval call, then converts that wrapper to character codes inside a function. The result is longer and less readable than the Light output.
With mangling on, the code is minified before encoding and variables declared with var, let or const are renamed to short hex-style names.
Realistic uses
- Adding a small barrier to a demo script or freelance deliverable before sending it to a client.
- Hiding hard-coded strings such as an internal label from casual view-source browsing.
- Creating obfuscated samples to test a deobfuscation or malware-analysis workflow.
- Learning how eval-based packers work by comparing input and output.
Be honest about the protection
This is encoding, not encryption. Anyone can decode the output in seconds by replacing eval with console.log, so never rely on it to hide passwords, API keys or licensing logic; the sample script that compares a hard-coded password shows exactly what not to do in production. Because the output uses eval, it can be blocked by a Content Security Policy that forbids unsafe-eval, it runs slightly slower, and it may trigger warnings in antivirus or ad-platform scanners. Output size grows considerably, and Aggressive mode is much larger than Light mode. Encoding runs in your browser.
Related Tools