JavaScript Minifier

Minify and format JavaScript — with size reduction stats

Free Client-Side No Login No Storage
Loading tool...

How to Use the JavaScript Minifier

  1. Paste your JavaScript.
  2. Choose Minify or Format mode.
  3. Click the action button.

Minifies JavaScript by stripping comments and collapsing whitespace. Preserves license comments (/*!). For production, consider Terser or esbuild.

What is JavaScript Minification?

The JavaScript Minifier is a client-side code compressor that strips comments, collapses redundant whitespace, removes unnecessary semicolons, and optimizes syntax without altering execution logic. It reduces JavaScript bundle sizes, accelerating page load speeds and decreasing bandwidth consumption.

Common Uses

  • Compressing standalone JavaScript utility scripts and snippets before web deployment
  • Reducing file transfer size for faster Core Web Vitals and Google PageSpeed scores
  • Removing inline development comments and debug statements from production code
  • Packaging lightweight client-side scripts without complex Webpack or Rollup build tools

Frequently Asked Questions

How does minification improve website performance?

Minifying JavaScript files reduces network payload size by 30% to 60%, allowing browsers to download, parse, and execute scripts significantly faster on mobile and desktop devices.

Does minifying JavaScript change variable names (mangling)?

This tool focuses on safe syntax compression and whitespace stripping without dangerous variable mangling, ensuring external global dependencies and API bindings remain intact.

Is it safe to minify code containing template literals and modern ES6+ syntax?

Yes. The parser recognizes ES6+ features including template strings (`` ` ``), arrow functions, classes, and async/await syntax, preserving string literals exactly.

Notes from this implementation

Shorter source, same behavior, until a name mattered

The minifier removes comments and compressible whitespace and, if the script is configured to, shortens local names. A name that is a string you look up from HTML (data-action handlers, a public API on window) must not be shortened. If the minifier has no list of names to keep, do not run it on a file that is used that way. Run it on a bundle that was built for that purpose, or only strip comments and whitespace.

This is not the JSON minifier. JavaScript has regex literals, template strings, and automatic semicolon insertion. A naive “remove newlines” pass can change which statement a slash belongs to. If the minified file throws and the original did not, diff the two around the throw, starting at the nearest regex or return.