RSRobince Studio

JavaScript Minifier

Paste JavaScript and compress it with Terser, the widely used minifier, directly in your browser. Choose mangling and compression options, see how many bytes you saved, and get a clear error with the line number if the code cannot be parsed.

Runs in your browser. Your files are never uploaded.

Loading JavaScript Minifier…

How to use JavaScript Minifier

  1. Paste your JavaScript into the input box.
  2. Tick the options you want, such as Mangle names, Compress or Drop console.
  3. Press Minify and wait a moment while Terser loads and runs.
  4. Review the size savings and copy the minified code.

What JavaScript minification does

A minifier rewrites source code into an equivalent program that takes fewer bytes. It strips comments and whitespace, shortens local variable and parameter names to single letters, and with compression enabled it simplifies expressions, removes unreachable code and inlines constants where it can prove that doing so is safe.

Smaller scripts download and parse faster. For large applications the savings are meaningful, particularly on mobile devices, where parsing time is a real cost as well as the download.

Choosing options sensibly

The default combination of mangling and compression suits most standalone snippets. Dropping console calls removes debugging output from production code, but make sure none of those calls have side effects you depend on, since the whole call expression is removed.

Top-level renaming gives the best savings but is the riskiest option, since globals can be referenced from other files, from HTML attributes or from the console. For scripts that are bundled into a single module, it is usually fine.

  • Keep the original source under version control and treat the minified file as a build artefact.
  • Always test the minified result with the same checks as the source.
  • Pair minification with gzip or Brotli on your server for the best transfer size.

Limits and privacy

This page minifies a single block of code. It cannot resolve imports, bundle several files or generate source maps, so it is best for snippets, bookmarklets, small widgets and quick checks. For a full application, use a bundler that applies Terser as part of its build.

Very large inputs can make the page pause for a few seconds. The engine downloads once as part of the page and runs locally, so your code is never sent to a server.

Why use this javascript minifier tool

  • Real Terser engine. The same minifier used in many build pipelines runs locally, loaded only when you first press Minify.
  • Adjustable options. Switch name mangling, compression, top-level renaming, console removal, ES module mode and licence comment retention.
  • Helpful errors. A syntax problem is reported with its line and column so you can fix it quickly.
  • Size report. Original and minified byte counts plus the percentage saved.

Frequently asked questions

Is minified code the same as obfuscated code?

No. Minification aims for smaller size, and name mangling is a side effect that makes the code harder to read. It is not security. Anyone determined can format the code and follow its logic, so never rely on minification to hide secrets or keys.

Why did my code stop working after minifying?

The most common cause is renaming top-level variables or functions that other scripts or inline HTML handlers refer to by name. Leave Top-level names unticked unless the script is fully self-contained. Code that depends on function names or Function.prototype.toString can also be affected.

Does it support modern syntax?

Terser understands current ECMAScript features such as arrow functions, classes, async functions and optional chaining. Tick ES module mode if your code uses import and export statements. TypeScript, JSX and other non-JavaScript syntax must be compiled first.

More free tools