Skip to content

JavaScript Minifier

Minify and compress JavaScript with Terser.

Runs in your browser · free · no sign-up

Input
Result

About the JavaScript Minifier

Shrink JavaScript files for faster websites. Terser is the same minifier used by Vite and webpack, so the output is safe and supports modern syntax like modules, classes and async/await.

JavaScript is often the heaviest part of a web page, and browsers must download, parse and run it before pages become interactive. Minifying it removes whitespace and comments and shortens local variable names, which can make files much smaller. Build tools do this automatically, but not every project has a build step: WordPress snippets, Google Tag Manager scripts, bookmarklets and small static sites benefit from a quick online minifier.

This tool uses Terser, the same minifier used by Vite, webpack and many other build tools, so it understands modern JavaScript including classes, async/await, optional chaining and ES modules. Options control whether local names are mangled, whether console calls are removed, whether licence comments are kept and whether the code is treated as an ES module. The result shows the size saving and can be downloaded.

How to use the JavaScript Minifier

  1. 1Paste your JavaScript.
  2. 2Choose options: mangle names, drop console.log, keep comments.
  3. 3Click Minify and copy the result.

Key features

  • Terser minification with modern syntax support.
  • Mangle local variable names.
  • Remove console.* calls.
  • Keep licence comments.
  • ES module mode, size saving and download.

Practical uses

  • Minifying a script for a WordPress site without a build step.
  • Shrinking a bookmarklet.
  • Preparing a small library file for a CDN.
  • Removing debug console output before release.

Example

A 12 KB utility file with comments and descriptive names often drops by around half with mangling on, while its exported functions keep their names and behaviour.

Tips and common mistakes

  • Keep the original source; minified code is very hard to edit.
  • Turn off mangling if other scripts access your functions by name in global scope.
  • Generate source maps in your real build pipeline for debugging production code.

Limitations

  • JSX and TypeScript must be compiled to JavaScript first.
  • Source maps are not produced.

Privacy

Your code is minified in the browser and never uploaded.

Frequently asked questions

Is the output safe to use?

Yes. Terser only performs transformations that keep the behaviour the same.

Why do I get a syntax error?

The input must be valid JavaScript. JSX and TypeScript need to be compiled first.

What does mangle do?

It renames local variables to short names like a and b, which saves a lot of space.

Does removing console calls affect errors?

It removes console.log, console.warn and other console calls, so nothing is printed. Errors thrown by your code still occur normally.

What does ES module mode do?

It tells Terser the code uses import and export, so top-level names can be optimised safely.

Related tools

Code BeautifierFormat JavaScript, CSS, HTML and JSON.
Syntax HighlighterColorful code for blogs and docs.
Code Diff ViewerCompare two code versions line by line.