JavaScript Minifier

Minify JavaScript with terser: removes whitespace and comments and shortens local names.

How to Use JavaScript Minifier

  1. Paste your JavaScript.
  2. Click Minify JavaScript. If there's a syntax error, you'll be told the line and column.
  3. Check the size saved, then Copy or Download the .min.js file.

A real minifier, not search-and-replace

The tool uses Terser, a JavaScript parser and minifier used inside many build tools. Because it understands the code rather than just deleting spaces, it doesn't make the classic mistakes of simple minifiers: code without semicolons keeps working, a + +b doesn't turn into a++b, and text inside strings and template literals is never changed.

It removes whitespace and comments, simplifies some expressions, and renames local variables and function parameters to short names. Global names and properties are left alone, so code that other scripts call still works. Comments marked /*! ... */ or containing @license are kept.

Before you publish

Keep your original file; minified code is hard to read and edit. Test the minified script once in your page. Terser is loaded only when you click Minify, so the page itself stays light. It supports modern JavaScript; TypeScript and JSX need compiling to plain JavaScript first.

Key Features & Practical Use Cases

  • Shrinking a script before adding it to a website or bookmarklet.
  • Minifying a small library or snippet without setting up a build tool.
  • Checking a script for syntax errors, since it must parse to be minified.

Frequently Asked Questions

Will minifying break my code?

Terser is designed not to change behaviour. Code that relies on function names at runtime (fn.name) can be affected by renaming, so test before publishing.

Does it obfuscate my code?

Partly, by shortening local names, but minified code can still be reformatted and read. It isn't protection.

Can it minify TypeScript or JSX?

No. Compile them to plain JavaScript first.

Is my code uploaded?

No. Terser runs in your browser.

About OneClickly

OneClickly is a set of 119 free tools for PDFs, images, text, everyday math and code. They run in your browser, so the files and text you work with stay on your device.

Related Tools

  • CSS Minifier - Remove comments and spaces from CSS to make the file smaller.
  • Base64 Encoder/Decoder - Encode text to Base64 or decode it back, with UTF-8 and URL-safe support.
  • URL Encoder/Decoder - Encode special characters in URLs (percent-encoding) or decode them.
  • HTML Encoder/Decoder - Escape special characters as HTML entities, or decode entities back to plain text.
  • JWT Decoder - Read the header, payload and expiry of a JSON Web Token in your browser.
  • Cron Expression Generator - Build cron schedule expressions and see what they mean in plain English.