Why obfuscate JavaScript?
Anything you ship to the browser - JS code, API endpoints, paywall logic, license checks - can be opened in DevTools in 3 seconds and read like a book. Obfuscation is not encryption (that is impossible by definition - the browser still has to execute the code), but it raises the skill bar so a casual `Ctrl+F` in the Sources panel finds nothing interesting.
Variables get renamed to things like `_0x4857`, strings move into an encrypted lookup table, control flow gets "flattened" and tangled, numbers become expressions (`5` becomes `0x1 + 0x4`). Everything still behaves identically at runtime.
Paste your code, pick a preset (Low / Medium / High) or toggle individual options, copy or download the result. Everything runs in your browser - the code never leaves your machine. That matters, because you are usually obfuscating exactly the kind of thing you do not want to share.
How to use
- Paste JavaScript code in the left panel or click "Upload file" to load `.js`, `.ts`, `.mjs` from disk.
- Pick a preset: Low (light makeup), Medium (sensible default), High (maximum scramble - slower runtime).
- Optionally expand advanced options and toggle individual flags (e.g. enable selfDefending, disable deadCodeInjection).
- On the right you see the obfuscated output plus a size comparison - the higher the preset, the larger the file.
- Test the result in DevTools - it should behave identically to the original. If anything breaks, drop the preset down.
- Hit "Copy" to paste into your bundler or "Download" to save as `obfuscated.js`.
- Ship the obfuscated version to production. Keep the original code private - the obfuscated file is the artifact, not the source.
When this helps
Concrete situations where obfuscation pays off:
- A proprietary client-side algorithm. For example a custom recommendation engine, an original sorting algorithm, a custom browser-game rule set.
- License validation in a SaaS app. The client has the JS, but a quick crack ("delete this `if (!valid) return`") is harder when `valid` no longer exists as a name.
- Hiding API endpoints. URLs and keys are still visible (to anyone determined enough), but they do not show up in a one-second grep.
- Protecting code from competitors. A small company shipping a SaaS library hosted by clients - obfuscation raises the cost of cloning your logic.
- Anti-tampering for widgets. Chat widgets, lead-gen forms, analytics snippets - obfuscation makes it harder to modify them live in the wild.
- Browser extensions and userscripts. If you distribute a userscript, obfuscation deters "fork and resell as my own".
Next, also optimize your SVG assets or convert HTML to JSX. For real client-side security use a strong password generator instead.