The JavaScript Minifier shrinks JS files with Terser, the same minifier most build tools use: it strips comments and whitespace, shortens local variable names, and simplifies code without changing what it does. Paste a script, choose whether to shorten names or keep /*! license */ comments, and copy or download the smaller file, which is handy when you need a quick minified build without a bundler. Everything runs in your browser, so your code is never uploaded.
Made for developers. Typical uses:
A 101-byte script that adds two numbers, with a comment and a console.log call, becomes 51 bytes: function add(d,n){return d+n}console.log(add(1,2)); With compress and renaming off it becomes 69 bytes, with the original names kept. A 141-byte snippet with an if (false) block shrinks to 72 bytes because the unused branch is removed.
It minifies one script at a time. It does not bundle files, resolve imports, create source maps or transpile for old browsers. Renaming can break code that reads function names or uses eval, in which case switch off "Shorten local variable names". Minified code is not a way to hide secrets.
Accuracy: Output is tested to keep behaviour unchanged. Keep your original files and test the minified version before you deploy it.
Expert Tip
Top-level names are only renamed in ES module mode, so global functions called from other scripts keep working by default. Test the minified build in a browser before you deploy it.
The JavaScript Minifier shrinks scripts with Terser, the minifier used by most JavaScript build tools. It removes comments and whitespace, shortens the names of local variables, and simplifies the code without changing what it does. You paste a script, choose from four options, press Minify, and see the size before and after. The result can be copied or downloaded as minified.js. The code is processed in your browser and is never uploaded.
This 101-byte script adds two numbers: a function called add with parameters first and second, a comment, and a console.log call. With the default settings, the result is 51 bytes: function add(d,n){return d+n}console.log(add(1,2)); The parameters have been renamed to single letters, the comment is gone and the spaces are removed, but the function name add is kept, because top-level names are not renamed unless the code is a module. With compression and renaming turned off, only whitespace and comments go, and the script is 69 bytes: function add(first,second){return first+second}console.log(add(1,2)).
Each checkbox changes how aggressive the minifier is.
Terser needs valid code. If the script has a syntax error, the tool reports the line and column, for example "JavaScript syntax error at line 1, column 10: Unexpected token". Fix the code first. For readable output instead of small output, use the JavaScript Formatter, which is the reverse operation for layout, although it cannot restore original variable names or comments.
Test the minified script as you would any new build. Code that reads function names, uses eval or relies on Function.prototype.toString can behave differently after renaming, so turn off "Shorten local variable names" if it does. Minified code is not secure or private: names are shortened but the logic is still readable to anyone determined, so never put secrets in client-side scripts. The guide to minifying CSS, JavaScript and HTML covers how this fits into a build, and the JSON Minifier and CSS Minifier handle other file types.
The tool minifies one script at a time and does not bundle files, handle imports, create source maps or transpile newer syntax for older browsers. A bundler does those jobs in a real project. This tool is for quick jobs and for seeing how small a script can get.
What minifying removes, how much it saves next to gzip and Brotli, and how to test minified CSS, JavaScript and HTML before you deploy it.
Explore more in Minifiers, read the guides and articles, or see how we test our tools.
Minify and compress CSS stylesheets to reduce file size.
Best for shrinking a stylesheet before deploying it to a production website to reduce load time
Minify and compress HTML code to reduce file size.
Best for shrinking a static landing page's HTML before deploying it
Minify and compress JSON data to reduce file size.
Best for reducing API response payload sizes
Format and beautify JavaScript code with proper indentation.
Best for making a minified third-party script readable enough to debug in dev tools
Test and debug regular expressions in real-time.
Best for testing regex patterns before using in code