Home › Generators › JavaScript Obfuscator
JavaScript Obfuscator
Anything you ship to a browser can be read by anyone who opens dev tools — but it doesn't have to be readable at a glance. This free javascript obfuscator rewrites your code with scrambled local names and encoded strings, so it runs identically and reads like static. Your code never leaves your device.
Nothing leaves your device. The obfuscator library loads from the jsDelivr CDN, but the code you paste is processed in your browser and never sent anywhere.
How it works
The tool runs the open-source JavaScript Obfuscator library (version 4.1.1) right in this page. When you press Obfuscate, the library parses your code into a tree, rewrites it, and prints the result — no server is involved at any step.
Three transformations do most of the work. Local renaming replaces the variable and function names inside your functions with generated names like _0x3f2a — names a reader learns nothing from. Global names are deliberately left alone, because other scripts, inline HTML handlers and server templates may depend on them, and renaming them is the classic way obfuscators break working pages. String encoding lifts your text literals — URLs, messages, class names, the readable fingerprints of your logic — into a separate array; the code fetches them by number at runtime, and with Base64 or RC4 chosen the array itself is unreadable. Compacting then squeezes the result onto as few lines as possible.
Two library features are intentionally never enabled here. Dead code injection pads the output with junk statements that never run — it inflates the file and can change timing, for protection that is mostly theater. Global renaming is off for the safety reason above. What you get is the setting combination a careful developer would choose for code they have not re-audited: same behavior, far less readable, minimal risk.
Obfuscation is not encryption, and this page won't pretend otherwise. The output still has to run in a browser, which means a skilled person with a debugger can always reconstruct what it does, given enough time. What obfuscation buys you is friction: casual copying stops being casual. Keep real secrets on a server, where they belong.
Worked example
The default code in the box is a tiny greeting function with one string in it. Press Obfuscate with Base64 encoding and compact output, and three things happen. The local variable message and the parameter name receive generated names. The readable text "Hello, " and "!" leaves the code and reappears as encoded entries in a string array at the top, fetched by index wherever they are used. And the whole program is compacted down to a dense block that still prints "Hello, World!" when run — the result area shows the before-and-after sizes so you can see what the protection costs in bytes: obfuscated output is usually larger than the tidy original, because the decoder helper and the string array come along for the ride.
Using obfuscated code safely
Always test the output. Run the obfuscated file through the same checks as the original — open the page, exercise the features, watch the console. Obfuscation is a build step, and build steps earn trust by testing, not by hope.
Keep the original safe. You cannot sensibly edit or debug the obfuscated version later. Archive the source (ideally in version control) before you ship the scrambled copy, or the next bug fix starts with an archaeology project.
Mind code that inspects itself. Programs that read their own function source (fn.toString()), rely on function names, or eval strings that reference local variables can behave differently after any obfuscator touches them. If your code does tricks like that, test those paths specifically.
FAQ
What does a JavaScript obfuscator actually do?
It rewrites working JavaScript into an equivalent program that is deliberately hard for a human to read: variables get meaningless names, string literals are pulled into an encoded array and fetched by index, and the code is compacted onto as few lines as possible. The browser runs it exactly the same way — obfuscation changes how the code looks, never what it does.
Is obfuscated JavaScript secure?
No — and no honest tool should claim otherwise. Obfuscation slows down a casual copyist and keeps honest people from simply reading your logic, but a determined developer with time and a debugger can always work out what browser code does, because the browser itself has to be able to run it. Never put passwords, private keys, or secrets in client-side JavaScript, obfuscated or not.
What is the difference between the string encoding options?
With no encoding, string literals are moved into an array but stored as plain text, so words from your code are still visible if someone opens the array. Base64 encoding stores them encoded, which hides the text at a glance. RC4 encoding also encrypts the array entries with a key embedded in the decoder, which is the strongest of the three and the slowest to run. All three are decoded at runtime by a small helper the library adds to your code.
Why doesn't this tool rename global variables or inject dead code?
Safety. Renaming globals breaks code that other scripts, HTML event handlers, or a server template rely on, and injecting dead code bloats the output and can change timing behavior. This tool keeps global names and the program's structure intact, and relies on local renaming, string encoding and compacting — the settings that are safe to apply to code you have not audited line by line. Test the obfuscated output before shipping it, as with any build step.
Is my code uploaded to a server?
No. The obfuscator library is loaded from the jsDelivr public CDN, but your code is processed entirely in your browser and is never sent anywhere — you can watch the network tab and see no request carrying it. Close the tab and both the input and the output are gone.