JS Minifier
Shrink JavaScript.
Shrink JavaScript.
How to use JS Minifier
- Paste your JavaScript source into the input box
- Run the minify to strip comments, trim lines, and drop blanks
- Compare the original versus minified byte size and percent saved
- Copy the smaller output for your production script
About JS Minifier
Paste your JavaScript and get a smaller version in one click. This is a safe, conservative minifier: it strips // line comments and /* */ block comments, trims the leading and trailing spaces on every line, and removes blank lines. Your string, template, and regex contents are left exactly as written, so a // inside a URL or a slash inside a regular expression is never touched. You also see the original versus minified byte size and the exact percentage saved, then Copy or Download the result.
Unlike a package you install from npm, or a compiler like Google's Closure, this runs instantly with no config and no toolchain to learn, handy when you just want to shrink a snippet the way tools such as Toptal's minifier do. It focuses on comments and whitespace only. It does not rename variables, obfuscate, or shorten identifiers, so if you need an obfuscator or maximum compression, reach for Terser or esbuild afterward. It also works one way: it minifies, but it does not reverse or de-minify code back into a readable format.
Use it on any plain JavaScript, or on the script you pull out of an HTML page or a PHP template before shipping. It is completely free, needs no signup, and runs entirely in your browser, so your code is never uploaded to a server, which makes it safe for private or proprietary work.
Frequently asked questions
- Is the JavaScript minifier free to use?
- Yes, it is 100% free with no signup, no limits, and no watermarks. Paste as much code as you like, as often as you like.
- Is my code uploaded or stored anywhere?
- No. All minification happens locally in your browser using JavaScript. Your source code never leaves your device and is never sent to a server, so it is safe for private or proprietary code.
- Does this rename variables or fully compress my code?
- No. This is a conservative whitespace-and-comment minifier. It removes comments, trims each line, and deletes blank lines, but it does not rename variables, shorten identifiers, or restructure code. For maximum compression, use a build-step tool like Terser or esbuild.
- Will it break my strings, regexes, or URLs?
- No. The tool tracks string literals, template literals, and regular expressions, so comments or slashes inside them (like // in a URL) are preserved exactly. It only strips comments and whitespace found in actual code.
- What exactly does it remove?
- It removes // single-line comments and /* */ block comments, trims leading and trailing whitespace on each line, and deletes empty lines. Internal spacing and newlines between statements are kept so the code stays valid and safe from automatic-semicolon-insertion surprises.
- Can it obfuscate my JavaScript too?
- No. This tool only minifies by stripping comments and whitespace; it does not obfuscate, scramble, or rename anything to make the code hard to read. If you specifically want an obfuscator, use a dedicated obfuscation tool, then run its output through a minifier if you still want it smaller.
- Can it un-minify or reverse minified JavaScript?
- No. This tool only makes code smaller, not more readable, so there is no de-minify or reverse mode. To un-minify code, use a JavaScript beautifier or prettifier, which re-indents the code, though it cannot recover the original comments or variable names.
- How does this compare to the Toptal or Google JavaScript minifier?
- It does the same core job of stripping comments and whitespace, but runs entirely in your browser with no ads and no account. Heavier tools like Google's Closure Compiler also rename and restructure code for smaller output, whereas this one stays conservative so it is far less likely to break your script.
- Can I minify the JavaScript inside an HTML file?
- This tool minifies JavaScript, not full HTML pages. Copy the code from between your script tags, paste it here, minify it, then paste the result back into your HTML. For minifying the HTML markup itself, you would need a separate HTML minifier.
- Can I use it to minify JavaScript in a PHP project?
- Yes. If your PHP files output or include JavaScript, copy that JavaScript out, minify it here, and drop the smaller version back in. The tool only processes the JavaScript you paste and does not touch PHP syntax, so keep the two apart.
- Do I need to install an npm package to use this?
- No. There is nothing to install and no npm package required; everything runs in this web page. If you prefer a command-line workflow that minifies automatically during a build, npm tools like Terser or esbuild are the usual choice.
- Should I test the minified output?
- Yes. Although the minifier is designed to be safe and non-destructive, you should always test the output in your project before shipping it to production, especially for large or unusual codebases.