Menu
Hide JavaScript • Runs the Same

JavaScript Code Hider

Hide your JavaScript source with Base64 or CharCodes. Output uses document.write — functions, event listeners, and everything else run exactly like the original. Paste, hide, test, deploy.

Base64 Mode CharCodes Mode Live Test Fully Working
JS Code Hider Live
Ready
JavaScript (Base64). Wraps your code in <script>document.write(atob("..."))</script>. The browser decodes and writes the original JS inline — functions and event listeners work normally.
Not encryption: This is encoding. Anyone can decode it. Use it for casual obfuscation — not for protecting passwords, API keys, or secrets.
JavaScript Input 0 chars
Hidden Output 0 chars
How This Tool Works

What This Tool Does

This tool hides your JavaScript source code by encoding it and wrapping it in a small bootstrap script. The output runs exactly the same as the original — functions, event listeners, DOM manipulation, everything works — but the source is unreadable to a casual viewer.

Two modes are available:

ModeHow It Works
JavaScript (Base64)Your code is Base64-encoded and wrapped in <script>document.write(atob("..."))</script>. On page load, the browser decodes the Base64 and writes the original code inline.
JavaScript (CharCodes)Each character is converted to its numeric character code. The wrapper rebuilds the string using String.fromCharCode, then writes it via document.write.

Why document.write (and not eval)

Many "JS hiders" use eval(atob("...")). That approach breaks real code in several ways:

  • eval runs in its own scope — var and function declarations do not become global.
  • Event listeners registered inside eval may lose their closure context.
  • Code that depends on window or global declarations fails silently.

The document.write approach avoids these issues entirely. It injects the original code directly into the page as a real <script> tag, so it runs in the global scope exactly as if you had pasted the original source.

How to Use the Output

  1. Paste your JavaScript into the input editor.
  2. Select a type — Base64 or CharCodes.
  3. Click Hide Code.
  4. Click Copy to copy the output, or Download to save it as a .html or .js file.
  5. Test it in the Live Test area below — the sandboxed iframe runs the hidden code and shows it works.
  6. Paste it into your page where the original script used to be.

Usage Example

If your original HTML was:

<script src="app.js"></script>

Replace it with the hidden version directly inline:

<script>document.write(atob("Y29uc29sZS5sb2coJ0hlbGxvJyk7..."));</script>

Or save the hidden output as a .js file and load it the same way you loaded the original.

What This Tool Cannot Do

  • It cannot encrypt. Base64 and CharCodes are reversible by anyone with atob() or a character-code decoder.
  • It cannot hide API keys. If your code contains a key, decoding reveals it.
  • It cannot prevent determined reverse engineering. Any developer can decode it in seconds.
  • It cannot replace real obfuscation. Tools like javascript-obfuscator rename variables and flatten control flow — this tool does not.

When to Use This Tool

  • Adding a light layer of protection to a small widget or demo.
  • Hiding a script from casual copy-paste.
  • Preventing simple scrapers from extracting inline JS.
  • Keeping minified code slightly less inviting to read.
  • Teaching yourself how Base64/CharCodes encoding works.

Common Issues

The output runs but nothing happens

Make sure your original code does not depend on being loaded before/after specific DOM elements. The hidden version injects at the same position where you paste it, so if the original needed DOMContentLoaded, the hidden version needs it too.

External scripts fail to load

If your code uses import or require, the hidden version will not work — those need module loading, not document.write. Encode only classic scripts.

Special characters break the wrapper

This tool handles all Unicode safely. Emoji, quotes, backslashes, and newlines are all escaped correctly.

Frequently Asked Questions

Will my functions and event listeners still work?
Yes — that is the whole point of using document.write instead of eval. The hidden code runs in the global scope exactly like the original.
Does my code get uploaded anywhere?
No. Everything runs in your browser using native JavaScript. Your code never leaves your device.
What is the Live Test area?
It runs the hidden output inside a sandboxed iframe so you can verify it works before deploying. It shows the console output and any errors — but does not affect your page.
Can I reverse the encoding?
Yes. Base64 mode can be reversed with atob() in any console. CharCodes mode can be reversed by converting the numbers back to characters.
Which mode should I use?
Base64 is shorter and cleaner. CharCodes is longer but slightly harder to spot at a glance. Use Base64 unless you specifically want the CharCodes look.
Can I hide large files?
Yes — limited only by your browser's memory. Upload is capped at 5 MB for convenience.
Does it work with modules (import/export)?
No. document.write is only for classic scripts. Module code needs type="module" and proper loading — use a bundler (Vite, esbuild, webpack) instead.
Is this the same as CodeMystify?
Similar concept — both use Base64 or CharCodes with document.write. This tool adds a Live Test sandbox and handles Unicode safely.
Does it work on mobile?
Yes. The UI is fully responsive and the sandboxed test iframe runs in mobile browsers.

Related Tools

External Resources