Skip to content
XUtilHub

JavaScript Minifier – Compress JS Online with Terser

Minify JavaScript to reduce file size with Terser: remove whitespace and comments, shorten variable names and compress code. See the bytes saved.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the JavaScript Minifier

Shrink JavaScript files with Terser, the minifier used by most build tools. Removes whitespace and comments, shortens variable names and simplifies code, and shows the size saved.

Key features

  • Powered by Terser
  • Removes whitespace and comments
  • Shortens local variable names
  • Compresses and simplifies code
  • Keeps license comments if you want
  • Shows the bytes saved

Make JavaScript files smaller

Smaller scripts download and parse faster, which improves page speed and Core Web Vitals. Minify a script before adding it to a site, or check how much smaller a file can get.

What minification does

TechniqueBeforeAfter
Remove whitespace and comments// add\nreturn a + b;return a+b
Shorten local namesfunction total(price, qty)function total(n,r)
Simplify expressionsif (x) { return true } else { return false }return!!x
Drop unreachable codeCode after returnRemoved

Typical savings are 30–60% before gzip, depending on comments and naming.

JavaScript formatter to reverse it, CSS minifier, and JSON minifier.

How to use the JavaScript Minifier

  1. Paste your code into the input box, upload a file, or click Sample to try it out.
  2. Choose the options you want, such as indentation, line width or dialect.
  3. The result appears instantly in the output panel. Syntax errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Is minified JavaScript safe to use?

Yes. Terser is the minifier behind webpack, Vite and most other build tools. It only applies changes that keep the code's behavior the same.

Why would minified code break?

Usually because code relies on function or variable names at runtime (for example via Function.name), or uses eval. Turn off 'Shorten variable names' if that applies.

Should I also gzip or Brotli-compress?

Yes. Minification and server compression work together: minify first, then let your web server compress the file. Most hosting does this automatically.

Does it support modern JavaScript?

Yes, including ES modules, async/await, classes, optional chaining and other modern syntax.

Is my code uploaded anywhere?

No. Every developer tool runs entirely in your browser, so source code, configuration files and passwords never leave your device.

Which formatter do you use?

HTML, CSS and JavaScript are formatted with Prettier, the most widely used code formatter, so the output matches what most projects use. SQL uses sql-formatter, and minification uses Terser and CSSO.

Is there a size limit?

There's no fixed limit. Very large files (several megabytes) can take a few seconds, depending on your device.

Last updated:

Related Dev tools