How to Obfuscate JavaScript or Unpack and Beautify It in the Browser
Learn how the JS Obfuscator wraps source code in a Base64 eval loader, how the Beautify mode unpacks it, and what the tool does not change.
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, and its Beautify mode reverses that wrapper or reformats packed code onto separate lines. Everything runs in the browser with btoa and atob, 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 break a packed one-liner onto new lines at braces and 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 lines at braces and semicolons 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 with Base64 and wraps it in a self-invoking function that decodes and evals it at runtime. Identifiers, comments and whitespace inside the original code are preserved inside the encoded string, so the output is larger than the input, not smaller.
Can Beautify mode deobfuscate code from other obfuscators?
Only partially. If the input contains an atob('...') call, the tool decodes that string and shows the original text. For any other input it applies simple formatting: a newline after each opening brace, closing brace and semicolon, with blank lines collapsed. It does not rename mangled identifiers.
Why does obfuscation fail on some scripts?
btoa only accepts characters in the Latin-1 range. If the script contains characters outside that range, such as emoji or many non-English characters in strings, the tool shows an error line instead of output. Escape those characters as \uXXXX sequences first and try again.