πŸ•ΆοΈ

JavaScript Obfuscator

βœ“ Free & no signup πŸ”’ Runs 100% in your browser Updated 2026-11-25 Website Management Tools

This tool is a basic JavaScript packer. You paste plain JavaScript, and it wraps your code in a disguise: the source is Base64-encoded, the resulting string is reversed, and the whole thing is hidden behind a short eval wrapper that decodes and runs it in the browser. The output looks like noise to a casual reader scrolling through your page source, and that is the entire point. What this tool is not is equally important: it is not encryption, not real security, and not a defense against anyone who actually wants to read your code.

Use it for the honest reasons: deterring lazy copying of a small demo or widget, hiding an Easter egg or a puzzle answer, or making a pasted snippet less obvious at a glance. Do not use it to protect API keys, license checks, game logic, or anything with real value, because a single atob call undoes everything this packer adds. This page explains exactly what the transformation does, how to run the result, what overhead and restrictions you accept, and the situations where you should not use it at all.

What the Packer Actually Does, Step by Step

The transformation is deliberately simple and fully reversible. Understanding each step tells you both how to deploy the output and how trivially it can be undone.

  1. Your original code is converted to UTF-8 bytes and Base64-encoded, so a line like var x = 42; becomes something like dmFyIHggPSA0Mjs=.
  2. The encoded string is reversed character by character, so the Base64 signature characters at the end move to the front. This defeats people who scan page source for atob wrappers by eye.
  3. The packer emits a tiny runner that undoes both steps at runtime: it reverses the string back, passes it to atob to decode, and hands the result to eval to execute. The wrapper also carries the UTF-8 handling so non-ASCII characters in your code survive the round trip.

A concrete example makes the size cost visible. Take the 21-character statement var greeting = "hi";. Base64 encoding alone expands it to 28 characters, and after reversal and the wrapper, which is roughly 90 characters of runner code, the packed output is around 120 characters for 21 characters of input. The overhead follows a fixed pattern: Base64 expands data by exactly 4 characters per 3 input bytes, about 33 percent, and the runner adds a constant of roughly 90 to 120 characters. On a 10 KB script you end up with about 13.5 KB plus the wrapper.

How to Use This Tool (Step by Step)

  1. Paste or type the JavaScript you want packed. Keep it to self-contained code that does not depend on being readable, debuggable, or source-mapped later.
  2. Click the pack button. The packed output appears in the result panel, ready to copy.
  3. Test the output immediately in a real page or console. If your original code threw a syntax error, the packed version will too, just less readably.
  4. Ship the packed string where you would have shipped the original: inline in a script tag, inside your own file, wherever the eval-based wrapper is allowed to run.
  5. Keep the original source. There is no unpack button here on purpose; the person who packed the code should always retain the readable original, because debugging packed output is miserable.

Running the Packed Output

The packed string executes the same way normal JavaScript does, because at run time the wrapper simply decodes and evals your code. Paste it into a script tag and the browser runs it exactly as if you had written the original. One practical detail matters: the wrapper needs eval to be available, so any environment that forbids eval will refuse the packed code even though the original would have worked fine.

EnvironmentDoes packed code run?Why
Ordinary web page, inline scriptYeseval is available by default
Page with a strict CSP (no unsafe-eval)NoContent Security Policy blocks eval entirely
Chrome extensions (Manifest V3)Noeval is disallowed in extension pages
Some sandboxed iframesDependssandbox tokens can remove eval capability

That CSP row deserves emphasis. A Content Security Policy without unsafe-eval is one of the best cheap defenses a site can deploy, and this packer's output is incompatible with it by construction. If your project has a strict CSP, packing is simply not an option, and no amount of tweaking the wrapper changes that.

When NOT to Use This Tool

  • Protecting secrets. API keys, tokens, and passwords inside packed JavaScript are still in your page, merely encoded. Anyone can unpack them in under a minute with a one-line reverse, decode, and eval-replacement. Treat client-side secrets as public, packed or not.
  • Enforcing licenses or paywalls. Any logic that runs in the user's browser is user-controllable. Packed license checks get bypassed routinely; enforcement belongs on a server.
  • Production performance-critical code. The eval wrapper costs a parse on every load and blocks some optimizations. For production, minification with a real tool like Terser gives smaller output without eval, plus source maps for debugging.
  • Anything under a strict CSP. As covered above, packed code and eval-restricting policies are mutually exclusive.
  • Compliance or legal protection. Obfuscated code that collects data or tracks users looks worse to auditors, not better, and obfuscation does not change what privacy laws require.

This Versus Real Minification and Obfuscation

It helps to place this tool on the spectrum of JavaScript protection, from weakest to strongest:

  • This packer (base64 + reverse + eval): seconds to undo, adds 33 percent size overhead, requires eval. Good for pranks, demos, and puzzles. Not for security.
  • Minifiers such as Terser: rename variables, remove whitespace and comments, apply dead-code elimination. Not aimed at secrecy at all, but they shrink output by 30 to 60 percent and remain CSP-compatible and debuggable with source maps.
  • Real obfuscators such as javascript-obfuscator: string arrays with rotation, control-flow flattening, dead-code injection, self-defending checks. These raise the effort needed to understand code from minutes to hours, though a determined reverse engineer still wins eventually.
  • Moving the logic server-side: the only approach that genuinely keeps code away from users. If the algorithm must stay secret, it must run on a machine you control.

Notice what all client-side options share: the code arrives on the user's machine and must be executable there, so it can always be recovered by someone patient. The only real variable is how much time and skill the recovery takes.

How to Unpack Output Like This (Know Your Enemy, and Yourself)

Knowing how trivially this scheme reverses is the best cure for over-trusting it. Anyone can undo the packer by replacing the eval call with a logging call: run the wrapper with eval swapped for console.log, or manually reverse the string, feed it through atob, and read the result. Our sister tool, the JavaScript deobfuscator, does exactly this unpacking automatically for eval and atob wrappers, including the reversed-string variant this packer produces. That symmetry is deliberate: pack and unpack are two views of the same transform, and seeing both sides in five minutes teaches more about obfuscation than an hour of theory. If you packed something and lost the original, that deobfuscator is also your recovery path.

Tips and Best Practices

  • Fix your code before packing. Packed output hides error line numbers and stack traces, so debug first, pack last.
  • Test on the target browsers after packing, especially if your code uses non-ASCII strings, since encoding round trips are where subtle bugs appear.
  • Version the original source, not the packed output. If you ever need to change one line, repacking from source beats hand-editing an encoded blob.
  • For small widgets where you want light deterrence plus smaller files, consider minifying instead; it is faster at runtime and friendlier to your CSP.
  • Never let a packed script lull you into shipping something sensitive client-side. Ask instead: could this check run on the server? If yes, move it there.

Frequently Asked Questions

Does JavaScript obfuscation protect my code from theft?
Only from the laziest copying. This tool's scheme, Base64 plus a reversed string behind an eval wrapper, reverses in seconds: anyone can decode the string and read your original source. Even heavyweight obfuscators only slow people down, because the browser must be able to execute the code, so it can always be recovered with enough patience. If your code contains genuinely valuable logic, the only real protection is running that logic on a server where clients never see it. Use obfuscation for deterrence, never for security.
Why does packed JavaScript break with a strict Content Security Policy?
The packed output executes your code through eval, and CSP policies without unsafe-eval forbid eval entirely, so the browser refuses to run the wrapper. Chrome extensions under Manifest V3 and some sandboxed iframes also block eval. Your original unpacked code would run fine under those policies because it never calls eval. If your site enforces a strict CSP, packing is not an option; use a minifier like Terser instead, which shrinks and mangles code without eval and stays policy-compatible.
How do I reverse or unpack this packed JavaScript?
The scheme reverses in one move: wherever the wrapper calls eval, substitute something that prints instead, such as console.log, and run it. The output is your original source. Manually, you reverse the string characters, decode with atob, and read the result. Our companion JavaScript deobfuscator tool unwraps this exact pattern automatically, including the reversed-string variant, without executing your code. Also keep your unpacked source safe somewhere, because repacking from readable source is far easier than reconstructing it from packed output.
Does obfuscating JavaScript make my page slower?
Yes, a little, and differently than you might expect. This packer adds roughly 33 percent to the encoded payload plus a small constant wrapper, so downloads grow. At runtime the wrapper must decode the string and eval it, which forces a fresh parse and forfeits some engine optimizations that benefit statically visible source. For a 10 KB script the total cost is modest, but on large bundles or hot code paths it is measurable. Production minifiers like Terser avoid eval entirely, shrink output instead of growing it, and keep full parse performance.
Can I hide API keys in obfuscated JavaScript?
No. Anything inside client-side JavaScript, obfuscated or not, reaches the user's browser and is recoverable. Base64 packing merely encodes the key, and decoding takes seconds; stronger obfuscation just delays extraction a little. Keys hidden this way get scraped constantly, which is why platforms like cloud providers require server-side proxies or restricted, referrer-limited keys. The correct pattern is simple: the browser calls your backend, and your backend holds the secret and talks to the third-party API. There is no client-side trick that changes this.
Is this the same as professional obfuscators like javascript-obfuscator?
No, and the gap is large. Professional tools apply string arrays with rotating indexes, control-flow flattening into state machines, dead-code injection, and self-defending checks, raising reverse-engineering effort from minutes to hours. This tool performs one encoding layer plus a reversal, which defeats casual skimming of page source and nothing more. That simplicity is also its appeal: output is tiny to produce, easy to reason about, and fully reversible with the matching deobfuscator. For demos, puzzles, and light deterrence it fits; for real protection, look to server-side logic.

Related Tools