JavaScript Minifier
Minify JavaScript
Heads-up: this is a safe surface-level minifier — it removes comments and insignificant whitespace but does not rename variables or eliminate dead code (that requires a real parser like Terser or esbuild). It also cannot use ASI (automatic semicolon insertion) rules to join lines, so with "Collapse line breaks" off, output stays multi-line. For production builds, use esbuild/Terser.
About this tool
This free JavaScript Minifier compresses your code to its smallest practical size by removing everything the interpreter does not need: comments, indentation, line breaks and redundant syntax. Paste your JavaScript — a library, a widget, a workers file, an inline script — and the minified result appears instantly, ready to deploy. Nothing to install, no account needed; minification happens as you paste. JavaScript is the most expensive asset type on the modern web, and not only because it is usually the largest. Unlike CSS, which the browser can apply while parsing, JavaScript is parsed, compiled and executed — and while that work happens on the main thread, the page is partially or fully blocked from responding. Every kilobyte removed from a script is kilobytes the browser never downloads, never parses and never compiles: minification here is not cosmetic, it directly reduces the time between page load and interactivity. This is why production JavaScript ships minified everywhere — and why shipping unminified script to users is leaving free speed on the table. Minification is also completely safe for well-written JavaScript in a way that hand-shortening never is. The minifier only removes or rewrites syntax the language spec declares optional — semicolons the parser infers, comments the interpreter skips, whitespace nothing reads. Your logic, your names, your behavior survive exactly as authored. What minification is *not* is obfuscation: the code becomes hard to skim, but determined readers can still reverse it, so never rely on minification to protect algorithms or embedded secrets — nothing in client-side JavaScript is secret. Everything runs locally in your browser. Your code is processed entirely by client-side JavaScript — nothing is uploaded, logged or stored on any server. Disconnect from the internet after the page loads and the minifier keeps working, which makes it safe for proprietary code, unreleased product logic, and anything you would rather keep on your own machine.
Frequently asked questions
What does JavaScript minification actually remove?+
Comments, indentation, line breaks, unnecessary semicolons and redundant syntax — everything the JavaScript engine ignores when executing code. Your logic, variable names, strings and behavior remain exactly as authored. Typical savings run 30–50% on development-written code, more on heavily commented files. The output is the same program in fewer bytes — what the browser *does* differently is only speed.
How do I minify JavaScript online with this tool?+
Paste your JavaScript into the input area — the minified result appears live, with original and minified sizes displayed so you see the exact saving. Copy it with one click and deploy it wherever the original lived: a .js file, an inline <script>, a worker. Keep the formatted original as your source of truth and minify the copy you ship — never edit minified output directly.
Can minification break my JavaScript?+
Not when the input is valid JavaScript — the minifier only touches syntax the spec marks optional. The real-world risks to know: code that *depends on function names* via toString() or reflection behaves differently when minified; anything reading comments (rare, but some tools embed config there) loses them; and files relying on sloppy-mode semantics that break in strict contexts were broken before minification. Modern code — modules, classes, standard APIs — minifies safely.
Is minifying JavaScript the same as obfuscating it?+
No — and the difference matters for what you can rely on. Minification optimizes for size and changes nothing semantically; obfuscation deliberately transforms code to resist human understanding. Minified code is *harder* to read but fully reversible by anyone determined — variable renaming and formatting can be partially undone by tools. Never treat minification as protection for algorithms, keys or embedded credentials: client-side code ships to the user, and anything the client has, the user has.
Why minify JS if my server sends it gzipped?+
Because minification and compression multiply, not substitute. The minifier removes bytes before gzip runs; smaller input compresses to smaller output, and the savings stack. Minification also saves where gzip cannot: parsing and compile time on the user's device, which depends on code size no matter how well the transfer was compressed. Gzip optimizes the network; minification optimizes the network *and* the CPU on every visitor's phone.
Does this tool also rename my variables?+
No — this minifier is conservative by design: it removes comments, whitespace and redundant syntax, and leaves your identifiers exactly as written. Aggressive renaming (mangling) squeezes out a few more percent but risks subtle breakage and destroys debuggability of stack traces. For most deployments, comment-and-whitespace minification captures the bulk of the savings with zero risk — which is exactly the trade this tool makes.
Does my JavaScript get uploaded to a server when I minify it here?+
No. All minification happens locally inside your browser using client-side JavaScript — your code never leaves your device, is never transmitted, and is never logged or stored. After the page loads you can disconnect from the internet and minification keeps working. That makes it safe for proprietary code, unreleased features and anything you would rather keep on your own machine.
Should I minify JavaScript during development or only in production?+
Only in production. Development runs on formatted code — readable, commented, debuggable — because stack traces, code review and breakpoints all depend on it. Minify as the last step before deployment, and configure source maps in your build if you need production errors mapped back to the original lines. The workflow here: develop formatted, then paste the final file, minify, ship the result.