JS Minifier & Beautifier
Safely compress JavaScript by removing comments and whitespace, or beautify minified code back to readable form. 100% client-side.
About JS Minifier & Beautifier
JavaScript files often contain comments, blank lines, and indentation that browsers do not need to execute — they are only there for humans. Removing them (minifying) reduces file size by 20–50%, improving page load speed and Core Web Vitals. On the flip side, minified JavaScript is nearly impossible to read, so developers frequently need to beautify (pretty-print) it back when debugging third-party scripts. This tool does both, using a tokenizer-based approach that respects strings, template literals, regex, and JavaScript syntax — so it will never break your code. It is a safe minifier that removes comments and whitespace but does NOT rename variables (unlike aggressive tools like Terser/UglifyJS).
How It Works
- Paste your JavaScript into the input box.
- Click "Minify JS" to compress it, or "Beautify JS" to pretty-print it.
- See the exact size savings (typically 20–50% for hand-written code).
- Copy the result or download it as a .js / .min.js file.
✨ Key Features
- ✓Minify JS — removes comments, whitespace, blank lines
- ✓Beautify JS — reformats minified code with proper indentation
- ✓Safe tokenizer-based approach (strings, regex, templates preserved)
- ✓Preserves Automatic Semicolon Insertion (ASI) safety
- ✓Handles template literals, regex, and nested strings
- ✓Live size comparison and savings percentage
- ✓Copy to clipboard with one click
- ✓Download as .js or .min.js
- ✓Instant processing — no server round-trip
- ✓100% client-side — no data sent to any server
🎯 Common Use Cases
- →Optimizing JavaScript for production deployment
- →Debugging third-party minified scripts
- →Preparing inline scripts for HTML <script> tags
- →Comparing original vs minified file sizes
- →Cleaning up exported JavaScript from build tools
- →Understanding obfuscated scripts
- →Preparing scripts for embedding in bookmarklets
- →Preparing scripts for CDN delivery
💡 Advanced Tips & Pro Insights
- ▸This tool removes comments and whitespace but does NOT rename variables. For maximum compression, use Terser or esbuild (they also rename locals and mangle properties).
- ▸For production, always follow minification with gzip or Brotli compression at the server level — they add another 70–80% reduction.
- ▸Never minify code you do not have the source for — minification loses variable names, formatting, and comments.
- ▸For modules (.mjs, ESM), minification should preserve import/export statements — this tool does.
- ▸Modern build tools (Webpack, Vite, esbuild, Rollup) include JS minification automatically. Use this tool for one-off cases or debugging.