Skip to content

Free JavaScript Minifier

Minify JavaScript by removing whitespace, comments and unnecessary characters. Reduce JS file size for faster load times. Free, with no sign-up required — everything happens right in your browser, so nothing you enter is sent to a server.

💻 JavaScript Minifier

How the JavaScript Minifier Works

Paste JavaScript, choose whether to strip comments and whitespace, and press Minify. The tool first splits the code into tokens, so it can tell real code from the inside of strings, template literals, regular expressions and comments. Comments are then removed, and whitespace is deleted wherever the language allows it, leaving a single space only between two words and a line break only where JavaScript's automatic semicolon insertion makes one significant.

Because it understands strings, a URL such as "https://example.com" inside quotes is not mistaken for a comment, and spaces inside text are never touched. The minifier does not rename variables, remove unused code or rewrite expressions, so it is safer but saves less than tools such as Terser or esbuild, typically 30 to 55% on well-commented code. We checked the output on large open-source libraries, and the minified versions still ran and produced the same results. For production work, use a build tool with source maps, and keep your original source.

Practical Use Cases

  • Reduce the size of a script before adding it to a web page or bookmarklet.
  • Strip comments and indentation from a snippet before sharing it.
  • Check how much of a file is whitespace and comments.
  • Prepare a small inline script for an email, embed or CMS field.

Tips for Best Results

  • Keep your readable source in version control and treat the minified file as generated output. You will not want to edit it later.
  • Test the minified script in the browser console or on a staging page. Code that relies on automatic semicolon insertion is the most sensitive to formatting changes.
  • Use a bundler with tree-shaking and source maps for larger projects. This tool is best for quick snippets and small scripts.

Frequently Asked Questions

It should not. The tool only removes comments and whitespace and keeps the spaces and line breaks that JavaScript requires. Test the result anyway, especially for code that relies on automatic semicolon insertion.
Yes. Their contents are preserved exactly, so // inside a string or a / in a regular expression is not removed.
Tools such as Terser rename local variables, remove dead code and simplify expressions. This tool deliberately does only the safe, whitespace-level work.
For small scripts, yes. For a larger project, use a build tool that can also produce source maps for debugging.
No. The minification runs in your browser.