Free Online JavaScript Obfuscator
Hide JavaScript from casual inspection by wrapping it in an encoded eval loader, or quickly collapse whitespace. Runs in your browser.
Input JavaScript
Paste or type the JavaScript code you want to obfuscate or minify.
Obfuscated Output
Your transformed JavaScript code will appear here.
About the JavaScript Obfuscator
Hide the source of a script from casual inspection, and learn what this kind of obfuscation can and can't do.
How it works
The Obfuscate button encodes your whole script as UTF-8 Base64 and wraps it in a small loader that decodes and runs it. For example, this input:
alert("Hi")
becomes:
eval(decodeURIComponent(escape(atob("YWxlcnQoIkhpIik="))))
When the browser runs this, atob decodes the Base64 text,
decodeURIComponent(escape(...)) restores any non-English
characters, and eval runs the original code. Someone opening
the file sees an encoded string instead of readable logic.
What it protects against, and what it doesn't
- It helps with: casual copy-and-paste of a script from view-source, and making a snippet less obvious at a glance.
- It doesn't help with: anyone who wants your code. Decoding the Base64 string recovers the original source exactly. Pasting it into the Base64 decoder is enough.
- It never makes secrets safe: API keys, passwords and private business rules in front-end JavaScript can always be extracted. Keep them on your server.
Things to check before deploying obfuscated code
-
Content Security Policy: if your site sends a CSP header
without
'unsafe-eval', the browser blocks the obfuscated script. Many security scanners also flagevalusage. - File size: Base64 adds about 33% to the file size, so minify first if size matters.
-
Debugging: stack traces point into
evalcode, which makes production errors harder to trace. Keep the original source and deploy the obfuscated copy.
About the Minify button
Minify collapses runs of whitespace and removes spaces
around { } ; , :. It's useful for quickly compacting short,
simple snippets. Because it works on plain text rather than parsing
JavaScript, it can break code that:
- uses
//line comments, because everything after the first one ends up on the same line and is commented out; - relies on automatic semicolon insertion (statements without
;at the end of a line); - contains strings or template literals where spacing matters.
For production bundles, use a parser-based minifier such as Terser or esbuild, which also shortens variable names safely.
How to use the tool
- Paste your JavaScript into the input editor.
- Select Obfuscate or Minify.
- Test the output in your application before deploying it.
- Select Copy or Download to save the result.
Frequently Asked Questions
It encodes your whole script as a Base64 string and wraps it in eval(atob("...")). When the browser runs the output, atob decodes the string and eval executes the original code. The code still works the same, but it can no longer be read directly in the file or in view-source.
Yes, easily. Anyone who recognizes the eval(atob(...)) pattern can decode the Base64 string and recover your original source exactly. This tool discourages casual copying; it doesn't protect intellectual property. For stronger protection, use a dedicated obfuscator that renames variables, flattens control flow and encrypts strings, and keep sensitive logic on the server.
In most cases, yes. Two situations need care: Content Security Policies that don't allow 'unsafe-eval' will block the obfuscated script, and the code runs through eval, which may behave differently in strict-mode modules. Always test the output in your application.
Minification removes whitespace and line breaks to make files smaller and faster to download. Obfuscation hides how code works. They're often combined, but they solve different problems. Base64-based obfuscation actually makes files about 33% larger.
No. The built-in minifier collapses whitespace with simple text rules. It doesn't parse JavaScript, so code with // line comments, code that relies on automatic semicolon insertion, or strings and template literals containing multiple spaces can be changed or broken. For production builds, use a parser-based minifier such as Terser or esbuild.
No. Obfuscation and minification run in your browser, and your code isn't uploaded to DevToolsWorld servers.