JS Minifier

Minify JavaScript with Terser and see the bytes saved.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

JS Minifier – Compress JavaScript Online

Smaller JavaScript downloads and parses faster, which improves page speed and Core Web Vitals. The JS minifier compresses your code with Terser, the minifier used by webpack, Rollup, Vite, and Next.js. After minifying you see the original size, the minified size, and the percentage saved.

What the minifier does

  • Removes whitespace and comments – line breaks, indentation, and comments are dropped.
  • Mangles names – local variables and function parameters get one-letter names. Exported names and globals are kept so your code still works with other scripts.
  • Compresses – constant expressions are folded, unreachable code is removed, if statements become shorter expressions, and repeated passes squeeze out extra bytes.
  • Keeps license comments if you want – comments starting with /*! or containing @license are preserved.

Options

  • Shorten variable names – turn off mangling to keep names readable while still removing whitespace.
  • Compress – turn off to only strip whitespace and comments.
  • Keep license comments – required by many open-source licenses when you redistribute code.
  • ES module – treat the input as a module (top-level names are local, import/export allowed). Turn off for classic scripts whose top-level functions must stay global.

Is minified code safe?

Terser is used in production by millions of sites. Your code behaves the same, as long as it does not rely on function names at runtime (fn.name) or eval with local variables. Always keep the readable source and minify as a build step.

To read minified code again, use the JavaScript Beautifier. Check syntax first with the JavaScript Validator, and minify the rest of your page with the CSS Minifier and HTML Minifier.

Frequently Asked Questions

Typically 30–70% before gzip, depending on how much whitespace, comments, and long names the code has. The savings chips show the exact numbers for your input.

Terser preserves behaviour for standard code. Code that depends on function or class names at runtime, or uses eval to access local variables, can be affected — turn off name shortening in that case.

Yes. Terser handles ES2020+ syntax including classes, async/await, optional chaining, and modules.

No. Terser runs in your browser.