Minify JavaScript
Compress and minify JavaScript by safely removing comments and whitespace. Shrink your script and see exactly how many bytes you save.
Free, no signup. Strings, template literals, and regex are never touched.
Editing is a pain in the ass, right?
That's why we're building Cubix. No more editing hell.
AI Video Editor
Drop your footage, tell it what you want. Cubix cuts, captions, color grades, and exports — fully on its own. No timeline. No manual work. Just results.
Cinematic Screen Recorder
Hit record on Windows. Auto-zoom, cinematic backgrounds, and studio-quality audio kick in automatically — your screen recording looks edited before you've touched a thing.
How to Minify JavaScript Online
Turn a formatted script into a compact, production-ready file in three steps.
Paste Your JavaScript
Drop in a function, module, or full script.
Minify
Click Minify JavaScript to strip comments and whitespace. You'll see original size, minified size, and bytes saved.
Copy or Download
Copy the compact code to your clipboard or download it as a .js file.
// before
function add(a, b) {
// sum two numbers
return a + b;
}// after
function add(a,b){ return a+b;}
Size Stats
See original size, minified size, bytes saved, and reduction percentage after every minification.
Behavior Preserved
Strings, template literals, and regex literals are scanned and left untouched.
Instant Results
Minification happens instantly. Copy to clipboard or download as a .js file.
Level up your editing workflow.
Get weekly insights on video editing, AI workflows, and creator growth straight to your inbox.
Frequently Asked Questions
What does the Minify JavaScript tool do?
It strips comments and collapses unnecessary whitespace from JavaScript code without breaking functionality, producing the smallest valid version of your script.
Is it safe for strings, template literals, and regex?
Yes. The minifier scans character-by-character and recognizes single/double-quoted strings, template literals, and regex literals, so their contents are never altered.
Does it change how my code behaves?
No. Only comments and whitespace are removed. Newlines that matter for Automatic Semicolon Insertion are preserved so behavior stays identical.
Is my code kept private?
Yes. Minification happens on request and nothing is stored, so it's safe to use with proprietary code.
How do I minify JavaScript without npm, webpack, or Node installed?
Paste the script here and click Minify JavaScript. There's nothing to install and no command line. Copy the compact output or download it as a .js file and upload that to your server.
How much smaller does minified JavaScript get?
It depends on how heavily commented and formatted the source is, but typical hand-written JavaScript shrinks by 20-40%. The tool shows the exact original size, minified size, and bytes saved after every run.
Does minifying JavaScript actually improve page speed?
Yes, though the gain is modest once gzip or brotli is in play. Smaller scripts mean fewer bytes to download and less to parse before the page becomes interactive, and it's one of the easiest render-blocking JavaScript warnings to clear in PageSpeed Insights.
What's the difference between minifying, uglifying, and obfuscating JavaScript?
Minifying removes comments and whitespace. Uglifying usually also renames local variables to shorter names. Obfuscating deliberately makes code unreadable to deter reverse engineering. This tool minifies, so your identifiers, strings, and logic stay exactly as you wrote them.
How do I minify JavaScript for a WordPress or Shopify theme?
Copy the contents of your theme's script file, minify it here, then save the result as a separate minified file and enqueue that one in production. Keep the original formatted file for editing so you always have a readable source.
Can I unminify JavaScript later?
You can reformat it. Run the minified output through our JavaScript Formatter to get indentation and line breaks back. Comments cannot be recovered once removed, so always keep your source file.
Is this free to use?
Yes. Minify JavaScript is completely free with no signup, no login, and no limits.
Related developer tools
Format code, minify CSS, and clean up markup in one place.