JavaScript Minifier

Formatters

How to use the JavaScript Minifier

Minify JavaScript in three steps:

1

Paste your JavaScript

Paste your JavaScript source code into the input panel, or upload a .js file using the upload icon in the panel header.

2

Choose options and click Minify

Enable 'Mangle Names' to shorten identifiers, 'Compress' to apply optimisation transforms, and 'Remove Comments' to strip all comments. Click 'Minify JS'.

3

Review savings and download

The stats bar shows before/after file sizes and percentage saved. Copy the minified output or download it as a .js file ready for production.


When to use this tool

Use the JavaScript minifier to reduce script size for production delivery:

  • Minifying standalone JavaScript files for static sites or CDN hosting without a build tool
  • Benchmarking how much Terser compression would save before adding it to a build pipeline
  • Compressing small utility scripts, widget code, or embed scripts for distribution
  • Reducing JavaScript payload to improve Lighthouse Performance and TTI (Time to Interactive)
  • Minifying Node.js lambda functions or serverless handlers to reduce cold-start size
  • Creating minified distribution files for open-source libraries before publishing to npm
  • Quickly reducing script size for HTML email templates or AMP pages with strict size budgets

Frequently asked questions

Q:What is the difference between 'mangle' and 'compress' in Terser?
Mangle renames local variables, function parameters, and internal function names to short, meaningless identifiers (a, b, c, d...). This reduces identifier length throughout the code. Compress applies a set of code transformation passes: dead code elimination, constant folding, inline expansion of small functions, simplification of boolean expressions, removal of unreachable branches, and more. Both can be applied independently. For maximum size reduction, enable both; to preserve readable identifiers in the output, disable mangle.
Q:Does minification with Terser change what my code does?
No — Terser's goal is always to produce output that is behaviourally identical to the input. Compression transforms are only applied when Terser can prove they do not change observable behaviour. If Terser cannot verify safety, it leaves the code unchanged. The minified output will run identically to your source in all JavaScript engines.
Q:What is Terser and how does it compare to UglifyJS?
Terser is a fork of UglifyJS that adds support for modern JavaScript (ES2015+). UglifyJS only processes ES5 code. Terser handles all modern syntax including arrow functions, destructuring, template literals, classes, async/await, optional chaining, and nullish coalescing. Terser is now the industry standard — webpack 5, Vite, Rollup, Parcel, and esbuild all use or recommend Terser for final minification.
Q:Can I minify ES Modules (import/export) with this tool?
Yes — Terser supports ES Module syntax including import, export, export default, and named exports. Static imports and exports are preserved in the output (Terser does not perform tree-shaking — that is a bundler concern). Dynamic import() calls are also preserved.
Q:Will mangling break my code if I use string-based property access?
Mangle only renames local variable names and function parameters — it does not rename object property names accessed via dot notation or string keys (obj.propertyName, obj['propertyName']) by default. If your code uses eval() or relies on function.name for runtime reflection, mangling those specific identifiers may cause issues. In such cases, disable 'Mangle Names' and use 'Compress' only.
Q:How does this compare to using webpack or Vite for minification?
webpack and Vite's Terser integration do everything this tool does plus tree-shaking (removing unused exports), module bundling, and code-splitting. For a full application, a build tool produces smaller output because it can eliminate entire modules. For standalone scripts, utility libraries, or content where you control the full file, this tool produces the same Terser result as a build tool would for that individual file.