What the JavaScript tools do
Three transformations for JavaScript source: format lays out minified or messy code with consistent indentation and line breaks; minify removes comments and whitespace to shrink it; and obfuscate rewrites it into a form that is hard to read while behaving the same. All three run in your browser, so proprietary code is not uploaded.
Format
Before:
const f=(a,b)=>{if(a>b){return a}else{return b}};for(let i=0;i<3;i++){console.log(f(i,2))}
After:
const f = (a, b) => {
if (a > b) {
return a;
} else {
return b;
}
};
for (let i = 0; i < 3; i++) {
console.log(f(i, 2));
}Formatting is purely cosmetic: it does not change semantics, rename anything or add or remove statements. Use it to read a library's minified build, a snippet pasted from a console, or code from a colleague who does not format.
Minify
| What is removed | What is not |
|---|---|
| Comments | Variable and function names |
| Indentation, line breaks, extra spaces | Statement structure |
| Optional semicolons where safe | String contents, regular expressions |
This is whitespace-level minification, safe for any valid script. Production build tools (esbuild, Terser, SWC) go much further — renaming locals, inlining, dead-code elimination — and typically cut size by half or more versus a third here. Use those in a build; use this tool for a quick snippet, an inline handler or a bookmarklet.
Obfuscate — what it does and does not protect
Obfuscation renames identifiers to meaningless ones, encodes string literals, and restructures control flow so that reading the code takes effort. It raises the cost of casual copying and makes logic harder to follow in the browser's devtools. It does not make code secret: JavaScript runs on the client, so anything obfuscated can be deobfuscated with enough time, and secrets (API keys, credentials, licence checks) placed in client code remain recoverable. Treat obfuscation as a deterrent, keep secrets on the server, and be aware that obfuscated code is larger and slower than minified code.
- Keep an unobfuscated copy in source control; obfuscated output is not editable.
- Test the output — aggressive transformations occasionally break code that relies on
Function.name,toString()oreval. - Do not obfuscate third-party libraries; it breaks their source maps and licences may require attribution.
Common uses
- Reading a minified bundle to trace a bug when no source map is available.
- Preparing a small script for an inline
<script>tag, a Tampermonkey userscript or a bookmarklet. - Lightly protecting a widget or embed snippet delivered to third parties.
- Normalising formatting before a diff.