JavaScript obfuscator
Encode JavaScript as a compact Base64 payload with a decoder wrapper. Optionally minify the code first.
What the JavaScript obfuscator does
This tool converts your JavaScript source into a Base64 payload and generates a decoder wrapper that evaluates the decoded source. The optional minify setting removes unnecessary whitespace before encoding, which can reduce the payload size. Processing happens when you submit the form; the result is shown here for you to copy.
How to use the obfuscator
- Paste a complete JavaScript script into the source editor.
- Enable Minify JavaScript before obfuscating if you want to compact the source first.
- Select Obfuscate JavaScript, then copy the generated output with the copy button.
- Run the output in a development or staging environment that matches the script context where it will be used.
Example
For example, the source console.log("Hello, world!"); becomes an eval wrapper containing an encoded payload. The generated wrapper decodes the payload at runtime and executes it.
When to use it
Use obfuscation when you want to make a client-side script less immediately readable or combine it with minification for a smaller transfer. It is a lightweight encoding step and does not replace code review, access controls, or server-side handling of sensitive operations.
Limitations and troubleshooting
- Base64 is reversible encoding, not encryption. Never include passwords, API keys, private data, or other secrets in code sent to a browser.
- Because the generated wrapper uses
eval, a site content security policy that disallows eval may block it. Review your policy before deploying the output. - Module statements such as
importandexportcannot run inside eval. Bundle modules into a regular script before using this tool. - Code relying on top-level module scope, source maps, or a specific script loading mode may behave differently. Test the output in its intended environment.
- If parsing fails, check that the input is complete JavaScript supported by the parser and remove surrounding HTML
<script>tags.
Frequently asked questions
Is my JavaScript encrypted or impossible to recover?
No. Base64 can be decoded easily. This tool makes source less readable at a glance but cannot prevent a browser user from recovering it.
Will the output be smaller than my input?
Not necessarily. The decoder wrapper adds overhead, and Base64 expands the encoded source. Minifying first can help, especially for larger scripts, but compare the character counts shown above.
Can I obfuscate ES modules with import or export?
No. Those statements are not valid inside eval. Bundle the module into a regular script first, then obfuscate the bundled output.
Why does the output fail under my content security policy?
The wrapper uses eval to execute the decoded source. Policies that prohibit eval block it. Consider a build-time obfuscation approach that does not rely on eval if your policy must remain strict.
Does the tool keep my code private?
The form submits source to this website for processing. Avoid submitting code containing credentials or other sensitive information.
Similar tools
CSS minifier helps you minify your CSS by removing all the unnecessary characters.
HTML minifier helps you minify your HTML by removing all the unnecessary characters.
Popular tools
UTM link generator helps you easily add UTM valid parameters and generate a UTM trackable link.
Random number generator helps you generate a random number between a given range.
PayPal link generator helps you generate a paypal payment link with ease.
HTML entity converter helps you encode or decode HTML entities for any given input.