Skip to content

Minify JavaScript

Shrink JavaScript with Terser, the minifier behind most build tools. Paste code or drop a file and it's minified as you type.

  • Runs in your browser
  • Code never uploaded
  • Free

Your JavaScript

Minified

What JavaScript minification does

Minification makes JavaScript smaller without changing what it does. It removes whitespace and comments, shortens local variable names, and rewrites code into shorter equivalents, such as turning if/else into ternaries.

Smaller scripts download and parse faster, which improves page speed and Core Web Vitals. Combined with gzip or Brotli on your server, a minified file is often a fraction of the original's transfer size.

  • Keep source maps for production debugging: minify from your build tool when you can; use this tool for quick one-off files and snippets.
  • Need it hard to read too? use the JavaScript Obfuscator.

How to minify JavaScript

  1. 01

    Paste or drop your code

    Paste JavaScript into the left box, or drop a file onto the page.

  2. 02

    It's minified instantly

    Terser minifies it as you type. Adjust the options above the editor if you need to.

  3. 03

    Copy or download

    Copy the result, or download it as a .min file. The size savings, including gzipped size, appear below.

Features

Four languages

JavaScript with Terser, CSS with CSSO, HTML with html-minifier-terser, and JSON.

Real savings

See original, minified and gzipped sizes, which is what visitors actually download.

Instant

Minification runs in a background thread as you type, so even large files stay responsive.

Clear errors

Syntax errors show the line and column so you can fix the source quickly.

Your code stays private

Nothing is uploaded. Minify proprietary code without sending it to anyone.

Free and open source

No limits, no sign-up, and the source is on GitHub.

Frequently asked questions

Is my code uploaded?

No. Minification runs entirely in your browser in a Web Worker. Your code never leaves your device.

Which minifier does this use?

Terser, the same engine used by webpack, Vite and most JavaScript build tools. It removes whitespace and comments, shortens variable names and simplifies code.

Will minified code behave the same?

Yes. Terser only makes changes that keep behaviour identical. If your code relies on function names at runtime, turn off Shorten names.

What does ES module do?

It lets the minifier understand import and export, and treat the file as strict mode. Turn it off for old-style scripts that rely on global variables.

Does it support modern JavaScript?

Yes. Classes, async/await, optional chaining, modules and everything else in modern ECMAScript is supported. TypeScript and JSX need compiling first.

Is minification the same as obfuscation?

No. Minifying makes code smaller and is easy to reverse with a formatter. To make JavaScript hard to read, use the JavaScript Obfuscator at obfuscate.devsamc.xyz.

More free tools