Free JavaScript Minifier Online

Free JavaScript minifier that removes comments and whitespace without breaking automatic semicolon insertion. Keeps license comments and shows the bytes saved.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow JavaScript Minification Works, and Why Line Breaks Matter →

About the JavaScript Minifier tool

JavaScript files often ship with explanatory comments, JSDoc blocks, blank lines and deep indentation. Browsers must download and parse all of it, so trimming the extra characters makes scripts load faster, especially on mobile networks. When you only need to shrink a snippet or a small file, setting up a full bundler is overkill.

This JavaScript minifier reads your code with a small tokenizer that understands strings, template literals (including nested ${…} expressions), regular expression literals and comments. It removes comments and unnecessary whitespace, and it joins lines only where doing so cannot change automatic semicolon insertion, for example after an opening brace, a comma or a semicolon, or before a closing bracket. A line break that separates two statements without a semicolon is kept, so code written in a semicolon-free style still runs.

To be clear about its limits: it does not rename variables, remove dead code or rewrite expressions the way Terser or esbuild do, so savings are smaller than a full optimising minifier. In exchange it is predictable, keeps /*! licence */ comments on request, and runs fully in your browser.

How to use JavaScript Minifier

  1. Paste JavaScript into “JavaScript input”, or use “Open file” for a .js, .mjs or .cjs file.
  2. Turn on “Keep line breaks (safest)” if you only want comments and indentation removed.
  3. Leave “Keep /*! license */ comments” on to preserve licence headers.
  4. Review the size tiles, then click “Copy” or “Download” for the .min.js file.

Features

ASI-aware line joining

Lines are merged only where automatic semicolon insertion cannot be affected.

Understands tricky syntax

Strings, nested template literals and regex literals such as /\/\// are copied untouched.

Two safety levels

Compact mode joins safe lines; “Keep line breaks” only strips comments and indentation.

Licence comments kept

Optionally keeps /*! … */ headers; a #! shebang line at the top is always kept.

Size and gzip savings

Before and after sizes, including gzip, are shown for every change.

When to use it

  • Minify a small widget or bookmarklet before pasting it into a page.
  • Shrink a script for a CMS field or tag manager that has a size limit.
  • Remove internal comments from code before sharing it with a client.
  • Quickly compare how much whitespace and comments add to a file.

Frequently asked questions

Does this JavaScript minifier rename variables?

No. It removes comments and whitespace only. Renaming (mangling) and dead-code removal need a full parser such as Terser, esbuild or SWC, which you would normally run in a build step.

Will my code still work after minifying?

It is designed to be behaviour-preserving: strings, templates and regular expressions are kept and line breaks that end a statement are preserved. For extremely unusual code, turn on “Keep line breaks (safest)” and test the output.

Does it support ES modules and modern syntax?

Yes. Because it works on tokens rather than a fixed grammar, import/export, async/await, optional chaining, classes and private fields pass through unchanged.

Can it minify TypeScript or JSX?

It will strip comments and whitespace from TypeScript, but it is intended for plain JavaScript. JSX text content may change, so compile JSX and TypeScript to JavaScript first.

Why keep /*! comments?

Many open-source licences require the copyright notice to stay with the code. The /*! prefix is the common convention for comments that minifiers should keep.

Related tools