AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I minify JavaScript?

Paste JS or drop a .js file into AnyTool's JavaScript Minifier and it compresses the code with a Terser-grade engine, showing the bytes saved. You can also beautify minified JS. Everything runs in your browser — your code never leaves your device.

  • Terser-grade minification (mangle, compress, dead-code removal)
  • Beautify mode to reformat minified or messy JS
  • Live compression stats and gzip-size estimate
  • 100% in your browser — code never leaves your device, free

What is

JavaScript Minification

JavaScript minification shrinks code by removing whitespace and comments, renaming local variables, and eliminating dead code — producing a smaller file that runs identically and loads faster. Beautifying does the reverse for readability.

Developer Tools

Related terms

TerserUglifyGzip SizeDead-Code Elimination

How to Minify JavaScript

Minify or beautify JavaScript entirely in your browser with live stats.

10 secWeb browser
  1. 1

    Add JS

    Paste your JavaScript or drop a .js file.

  2. 2

    Pick a mode

    Choose minify for the smallest output or beautify to reformat.

  3. 3

    Copy or download

    See the bytes saved and copy or download the .min.js.

Result: Minified or beautified JavaScript

Frequently Asked Questions

No — minification runs in your browser, so your code never leaves your device.

AnyTool minifies JS locally with a bundled Terser engine in a Web Worker (no runtime CDN), so it works offline and your code is never POSTed to a server — unlike Toptal or Minifier.org which process server-side.

Yes — it uses a modern ES2020+ capable engine, not the old UglifyJS.

The minifier is built on Terser, which handles modern ECMAScript syntax (arrow functions, classes, optional chaining, modules), so it won't break on current code the way older minifiers do.

Yes — switch to beautify mode to reformat minified or messy JS.

The same tool reformats compressed or unformatted JavaScript with proper indentation, so you can both shrink and tidy code in one place.

Detailed Explanation

Methodology

How JavaScript Minification Works

AnyTool minifies JavaScript with Terser, the industry-standard engine that handles modern ECMAScript (ES2020+) syntax — whitespace/comment removal, identifier mangling, and dead-code elimination. A beautify direction uses Terser's format options to reformat minified or messy code. Terser runs in a Web Worker so large files don't block the UI, and a gzip size estimate is computed locally via CompressionStream. The engine is bundled (no runtime CDN), so code never leaves the device.

  • Terser engine — modern ES2020+ minification
  • Mangle, compress, and dead-code elimination
  • Beautify direction for readable output
  • Runs in a Web Worker; live gzip-size estimate
  • Bundled, no runtime CDN; code never leaves the device