lobsite! Sign in Sign up

Free · runs in your browser · no sign-up

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.

Minify your JavaScript

JavaScript formatter →
Minified

Next Minify the HTML too: HTML Minifier → Publish your site ↓

How to use the JavaScript minifier

  1. Add your JavaScript

    Paste it, open a .js file, or start from the sample.

  2. See the savings

    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 or download it

    Save it as script.min.js.

What JavaScript minification 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 minifying JavaScript 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.

JavaScript minifier FAQ

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.

Publish your site with the smaller scripts

Drop the folder, or run one command. Free, and live in seconds.

All formatters and minifiers →