How to Obfuscate JavaScript or Unpack and Beautify It in the Browser
Learn how the JS Obfuscator wraps source code in a light Base64 eval loader, how the Beautify mode unpacks and re-indents it, and what it does not protect.
JS Obfuscator & Beautifier
Introduction
Frontend JavaScript ships in plain text, so anyone can open DevTools and read the logic. The JS Obfuscator wraps a script in a Base64 encoded eval loader so casual readers see an encoded blob instead of the source. It is light obfuscation that deters casual copying, not protection: it is trivially reversible, and the Beautify mode itself undoes the wrapper or re-indents packed code. Everything runs in the browser, and nothing is sent to a server.
Step-by-Step Instructions
- Paste the script into the Source JavaScript Code box; the character count updates as you type.
- Keep the Obfuscate Code mode selected to generate the Base64 eval wrapper in the Obfuscated JS Output panel.
- Switch to Beautify / Deobfuscate Code to unpack a wrapper produced by this tool or to re-indent a packed one-liner, with line breaks at braces and statement-ending semicolons.
- Review the output panel, which refreshes instantly on every edit without a separate run button.
- Click Copy Code to place the result on the clipboard and paste it into your build or page.
Key Use Cases
- Quick Code Hiding: Wrap a small widget script before pasting it into a CMS where the source would otherwise be readable in place.
- Unpacking Loaders: Recover the original text from an atob eval wrapper that was produced by this tool.
- Line Formatting: Spread a minified one-line script across indented lines so it is easier to skim.
Frequently Asked Questions
Does this tool rename variables or minify the code?
No. Obfuscate mode encodes the whole script as UTF-8 and then Base64, and wraps it in a one-line loader that decodes it and runs it with indirect eval, (0,eval)(...), in the global scope. Top-level functions and var declarations stay global, so inline handlers such as onclick keep working. Identifiers, comments and whitespace inside the original code are preserved inside the encoded string, so the output is larger than the input, not smaller. Because it relies on eval, it will not run on pages whose Content Security Policy omits 'unsafe-eval'.
Can Beautify mode deobfuscate code from other obfuscators?
Only partially. If the input contains an atob('...') call, the tool decodes that string as UTF-8 and re-indents the original text. For any other input it re-indents the code, breaking lines after braces and statement-ending semicolons while leaving strings, template literals, comments, regular expressions and for loop headers intact. It does not rename mangled identifiers.
Does it work with emoji or non-English text in strings?
Yes. The script is converted to UTF-8 bytes with TextEncoder before Base64 encoding, and the loader decodes it with TextDecoder, so emoji, accented letters and other scripts come through unchanged.