Minifiers

JavaScript Minifier

Basic JavaScript minification: remove comments, collapse whitespace, and reduce file size.

Minified JS will appear here...

What Is JavaScript Minification?

JavaScript minification is the process of removing unnecessary characters from source code without changing its functionality. This includes stripping comments, collapsing whitespace and newlines, and shortening code where possible. The result is a smaller file that loads faster over the network, improving page load times and reducing bandwidth costs.

A typical JavaScript file contains significant amounts of whitespace, comments, and formatting that are essential for developers reading the code but completely irrelevant to the browser executing it. Minification can reduce file sizes by 30-60% depending on how heavily commented and formatted the original code is. Combined with gzip compression, total transfer size reductions of 70-80% are common.

This online JavaScript minifier performs basic minification: removing single-line and multi-line comments, collapsing whitespace, and removing unnecessary spaces around operators and punctuation. It preserves string literals, template literals, and regex patterns. All processing happens in your browser — your code never leaves your machine. For production builds, consider full-featured minifiers like Terser or esbuild that also perform variable renaming and dead code elimination.

How to Minify JavaScript Online

  1. Paste your JavaScript — Copy your JavaScript code into the input panel on the left. The editor accepts any valid JavaScript including ES6+ syntax.
  2. Click "Minify" — The minifier strips comments, collapses whitespace, and removes unnecessary spacing to produce the smallest output.
  3. Review the stats — See the original size, minified size, and percentage reduction displayed below the output.
  4. Copy the result — Click "Copy" to copy the minified code to your clipboard, ready to use in your project.

Key Features

  • Comment removal — Strips both single-line (//) and multi-line (/* */) comments while preserving comments inside strings.
  • Whitespace collapsing — Reduces multiple spaces, tabs, and newlines to the minimum required for valid JavaScript.
  • String preservation — Correctly handles single-quoted, double-quoted, and template literal strings without modifying their contents.
  • Regex support — Preserves regular expression literals without mangling their syntax.
  • Size statistics — Shows original size, minified size, and percentage reduction in both bytes and kilobytes.
  • 100% client-side — Your JavaScript code never leaves your browser. No server, no uploads, no tracking.

Common Use Cases

  • Quick minification — Minify a script snippet before embedding it inline in an HTML page or email template.
  • Estimating savings — Check how much size reduction minification would provide for a given file before setting up a full build pipeline.
  • Bookmarklet creation — Minify JavaScript to fit into a browser bookmarklet URL, where every byte counts.
  • Learning tool — See how minification transforms readable code and understand what gets removed versus what must be preserved.
  • Ad-hoc scripts — Quickly minify one-off scripts that don't warrant a full build tool configuration.

Frequently Asked Questions

🔒 This tool runs entirely in your browser. No data is sent to any server.