JavaScript Minifier
Trim comments and unnecessary blank lines from a JavaScript file to reduce its size.
How to use the javascript minifier
- Paste your JavaScript into the input box.
- Click Minify.
- Copy or download the result, and test it before deploying.
Features
- Strips block and line comments
- Removes blank lines and leading/trailing whitespace per line
- Copy or download as a .js file
What this JavaScript minifier is for
This tool is intended for light client-side minification: removing comments and avoidable whitespace to make straightforward scripts smaller. It is not a full compiler, bundler or optimiser and does not perform advanced transformations such as tree shaking.
Always keep the readable source version and test the minified output. Complex regular expressions, template-generated code or unusual syntax are safer with a production build tool such as a dedicated JavaScript minifier integrated into your project.
If a script is part of a larger application, source maps and a proper build step make production errors easier to diagnose. A quick browser minifier is better suited to small standalone snippets than a full application bundle.
Frequently asked questions
Related tools
Keep a debuggable JavaScript source
Minification makes production files smaller but harder to inspect. Maintain the readable source separately, and test the minified result because aggressive transformations can expose assumptions that were hidden during development.
- Run your normal functional tests after minifying.
- Keep source maps when practical.
- Use HTTP compression and caching as well; minification is only one part of delivery optimisation.
Related reading: What “runs in your browser” means for privacy