Skip to content
toolgrid

No tool found. Try another word.

JavaScript Minifier

Minify JavaScript with Terser: removes whitespace and comments, shortens variable names and optimizes code. Supports modern ES2015+ syntax and modules.

Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.

How to use the JavaScript Minifier

  1. 1 Paste your JavaScript.
  2. 2 Choose whether to compress, shorten names and keep license comments.
  3. 3 Copy the minified code or download it as script.min.js.

About the JavaScript Minifier

Minifying JavaScript makes scripts smaller so they download and parse faster. The minifier uses Terser, the same tool that webpack, Vite and Rollup use for production builds, so the result is what you would get from a professional build pipeline.

Terser removes whitespace and comments, shortens local variable and function names (mangling) and applies safe optimizations such as removing unreachable code, simplifying conditions and joining declarations. Global names and object properties are kept, so your code still works with the rest of the page.

If your code uses import or export, it is minified as an ES module. When Terser can't parse the code, you get the error with its line and column. License comments (/*! … */ or @license) can be kept with "keep comments", which many open-source licenses require.

Frequently asked questions

Will minified code behave the same?

Yes, Terser only applies transformations that keep the behaviour. Code that relies on function names (fn.name) or on eval may be affected by mangling; switch name shortening off in that case.

How much smaller does it get?

Typically 30–60%, depending on comments and name lengths. With gzip or Brotli the transfer size drops much further.

Can minified code be reversed?

Only partly: the JavaScript formatter restores the layout, but shortened names and removed comments are gone. Keep your original source.

Should I use this instead of a bundler?

For a single script or a quick test, yes. For an application, let your build tool minify automatically, with source maps for debugging.