GALAXY OF TOOLS

DEV SECTOR

JS Minifier

Minify JavaScript with Terser — mangle names, compress code and keep licence comments.

The minifier (Terser, about 1 MB) loads the first time you press the button.

Runs entirely in your browser. Nothing you enter or upload is sent to a server.

Minify JavaScript online with Terser

The JS Minifier makes JavaScript files smaller so web pages download and start faster. It uses Terser, the widely used open-source JavaScript minifier behind many modern build tools, running directly in your browser. Paste a script or load a .js file and get a compact version with comments and whitespace removed, local variable names shortened and dead code dropped.

Unlike a simple whitespace stripper, Terser fully parses your code, so it understands scope, strings, regular expressions, template literals and automatic semicolon insertion. That means the minified file behaves exactly like the original. If the code cannot be parsed, you get the exact line and column of the syntax error with the surrounding lines highlighted, instead of a broken file.

Your code is never uploaded. Terser is downloaded once from a public CDN, and every minification runs on your own device.

How to use the JS Minifier

  1. Paste JavaScript into the JavaScript to minify box, drop a .js file onto it, or press Load file.
  2. Choose options: mangle names, compress code, keep licence comments, ES module, mangle top-level names or drop console.* calls.
  3. Set the Output syntax. Keep ES5 if the script must run in very old browsers; choose ES2015 or ES2020 to allow shorter modern syntax.
  4. Press Minify JavaScript. The first press loads Terser; after that, the output refreshes as you edit.
  5. Check the size panel, then press Copy or Download .js to save the result as a .min.js file.

JS Minifier features

Powered by Terser

A real JavaScript parser and optimiser, so the result is functionally identical to your source.

Mangle and compress

Local names become one or two letters, constant expressions are folded, unreachable branches are removed and two compression passes squeeze out extra bytes.

Licence comments kept

Comments containing @license or @preserve, or starting with /*!, stay at the top of the output when the option is ticked.

Exact syntax errors

Parse errors show the line, the column and a code excerpt with a caret pointing at the problem.

Modern JavaScript support

Handles ES2022 syntax such as classes, optional chaining, async/await, BigInt and ES modules with import and export.

Size and gzip estimate

Compare original, minified and gzipped sizes to see the real-world saving.

What each option does

OptionEffectWhen to change it
Mangle namesRenames local variables and function parameters to short names like n and t.Untick only when debugging production errors without source maps.
Compress codeRewrites code into shorter equivalents and removes dead code, such as if (false) { … } blocks.Untick for whitespace-and-names-only minification.
Keep licence commentsPreserves /*!, @license and @preserve comments.Untick if your licence allows the notice to be stored elsewhere.
ES moduleParses the input as a module, allowing import, export and top-level await, and treats it as strict mode.Tick for files loaded with <script type="module"> or bundler entry points.
Mangle top-levelAlso renames top-level functions and variables.Only safe when no other script calls those names, for example in a bundle or module.
Drop console.*Removes console.log, console.warn and other console calls.Tick for production builds that should not log.

Understanding the output

Minified code is meant for browsers, not people. It usually sits on one line, uses short names and replaces readable constructs with compact ones: true may become !0, if statements may become && or ternary expressions, and several var statements are merged into one. All of these are exact equivalents, so behaviour does not change.

Top-level names are kept by default because other scripts on the page may rely on them — in the sample, calculateOrderTotal stays readable while its local variables shrink. Global objects such as window, document and Math are never renamed. If your file is a self-contained module or bundle, ticking “Mangle top-level” shrinks it further.

To make minified code readable again for debugging, paste it into the Code Beautifier. Stylesheets and markup can be shrunk with the CSS Minifier and HTML Minifier.

Tips for the smallest safe result

  • Keep your original source in version control and treat the .min.js file as a build artefact you can regenerate at any time.
  • Serve minified files with gzip or Brotli compression enabled on your server or CDN. The two savings stack.
  • Choose ES2015 or ES2020 output only if every browser you support understands that syntax; otherwise keep ES5.
  • If something breaks after minifying, untick options one at a time to find the cause — code that relies on Function.prototype.name may need “Mangle names” switched off.

JS Minifier FAQ

Is this JavaScript minifier free and private?

Yes. It is free with no sign-up or file limits. Terser runs inside your browser, so your code is never sent to a server.

Will minified JavaScript behave the same?

Yes, as long as the code does not depend on the exact names of local variables or functions. Terser only applies transformations that keep behaviour identical. Code that reads function names at runtime, or uses eval to reach local variables, may need mangling switched off.

Why do I get a syntax error?

Terser has to parse your code completely. The error shows the line and column where parsing stopped — often a missing bracket, a stray comma or TypeScript or JSX syntax, which must be compiled to plain JavaScript first. Tick “ES module” if the code uses import or export together with top-level await.

What is the difference between minifying and obfuscating?

Minifying makes code smaller and, as a side effect, harder to read. Obfuscation deliberately makes code hard to understand, often making it larger and slower. This tool minifies; it does not protect your code from being read.

Does it support ES6, async/await and modules?

Yes. Terser understands modern JavaScript, including classes, arrow functions, destructuring, optional chaining, async/await, generators and ES modules.

How much smaller will my file be?

Typical hand-written scripts shrink by 40–70% before gzip, depending on how many comments and long names they contain. The size panel shows the exact figures for your code.

You might also need