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:
| Mode | How 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:
evalruns in its own scope —varandfunctiondeclarations do not become global.- Event listeners registered inside
evalmay lose their closure context. - Code that depends on
windowor 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
- Paste your JavaScript into the input editor.
- Select a type — Base64 or CharCodes.
- Click Hide Code.
- Click Copy to copy the output, or Download to save it as a
.htmlor.jsfile. - Test it in the Live Test area below — the sandboxed iframe runs the hidden code and shows it works.
- 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-obfuscatorrename 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?
document.write instead of eval. The hidden code runs in the global scope exactly like the original.Does my code get uploaded anywhere?
What is the Live Test area?
Can I reverse the encoding?
atob() in any console. CharCodes mode can be reversed by converting the numbers back to characters.Which mode should I use?
Can I hide large files?
Does it work with modules (import/export)?
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?
document.write. This tool adds a Live Test sandbox and handles Unicode safely.Does it work on mobile?
Related Tools
External Resources
- MDN: document.write()
- MDN: atob()
- MDN: String.fromCharCode()
- CodeMystify on GitHub — inspiration for this tool