JS minifier
Minify your JavaScript by removing all the unnecessary characters.
About this tool
The JS minifier makes JavaScript files smaller by removing comments, extra whitespace and line breaks, while keeping the code working exactly as before. It shows how much it saved, in percent and bytes.
How to use the JS minifier
- Paste your JavaScript.
- Press Minify.
- Copy the result into your site, or into a .min.js file.
What it does and doesn’t do
It removes comments and whitespace, and the line breaks and semicolons the code doesn’t need. It’s careful with strings, regular expressions and template literals, so their contents aren’t touched.
It doesn’t rename variables or rewrite your code, as bundlers like esbuild and Terser do. That makes the result a little bigger than theirs, but easy to read back and very unlikely to break anything.
Tips
- Keep the readable original for editing, and minify a copy for the live site.
- If it reports an error, the code has a syntax problem, such as a missing bracket.
- On a larger project, a build tool like Vite minifies every file automatically each time you build.
Similar tools
JSON validator & beautifier
Validate JSON content and make it look good.
SQL formatter/beautifier
Format & beautify your SQL code with ease.
HTML entity converter
Encode or decode HTML entities for any given input.
BBCode to HTML
Convert forum style BBCode snippets to raw HTML code.
Markdown to HTML
Convert Markdown snippets to raw HTML code.
HTML tags remover
Easily remove all HTML tags from a block of text.