lobsite! Sign in Sign up

Free tools /

JavaScript Minifier

Minify JavaScript with Terser: shorter names, no whitespace or comments, dead code removed. See how many bytes you save. Free, in your browser.

JavaScript formatter →
Minified

How to use it

  1. Paste your JavaScript, open a .js file, or start from the sample.
  2. The minified code appears as you type, with the size before and after. A syntax error is shown with its line and column.
  3. Copy it or download it as script.min.js.

What it does

The JavaScript Minifier runs Terser, the minifier inside most build tools:

  • Removes whitespace and comments.
  • Shortens local variable and parameter names (first becomes n). Top-level names stay as they are, so other scripts on the page can still call your functions.
  • Removes code that can never run, and simplifies expressions (if (x) { return a } else { return b } becomes return x ? a : b).

Is it worth it?

JavaScript is the most expensive thing a page loads: it has to be downloaded, parsed and run. Minifying usually halves a script's size before gzip or Brotli compression, and often still saves a third after it, because shorter names and missing comments compress too. Build tools such as Vite and esbuild minify for production already; this page is for scripts you write and ship by hand, and for checking what minification does to a snippet.

Frequently asked questions

Can minifying break my code?

Terser keeps the meaning of valid code. Code that reads its own function names or source text at run time (rare) can behave differently. Keep the readable version as your source and test the minified one.

Does it support modern JavaScript?

Yes, including modules, classes, async/await and optional chaining. It doesn't change which browsers your code runs in.

What about source maps?

This page doesn't make them. Build tools write source maps alongside the minified file, which lets browser developer tools show your original code.

Is my code uploaded?

No. Terser loads into your browser and runs there.