Skip to content
AllToolsDesk

Popular

  • JSON Formatter & ValidatorFormat, minify and validate JSON with error locations.
  • CSS FormatterBeautify CSS, SCSS and Less with Prettier.
  • CSS MinifierCompress CSS and see the bytes saved.
  • JavaScript FormatterBeautify JavaScript and TypeScript.
  • JavaScript MinifierMinify JavaScript with Terser.
  • HTML FormatterIndent HTML, including inline CSS and JS.
  • JPG to PDFTurn images into a PDF, one per page.
  • Merge PDFCombine several PDFs into one file.
38 free toolsSee all tools

JavaScript Minifier

Minify JavaScript with Terser: removes whitespace and comments, shortens variable names and simplifies code. Runs locally in your browser.

Runs in your browser. Nothing is uploaded.

Ready.

About the JavaScript Minifier

JavaScript is usually the heaviest part of a web page after images, and it must be downloaded, parsed and compiled before it runs. Minification shrinks it without changing what it does, which speeds up loading on slow connections and mobile devices.

This tool uses Terser, the minifier behind many popular build tools. Besides removing whitespace and comments, it can shorten local variable names and simplify expressions, often halving the size of hand-written code. That is useful for inline scripts, small widgets, bookmarklets, or checking how much a file could shrink before adding a build step to a project.

How to use the JavaScript Minifier

  1. 1

    Paste your JavaScript, open a .js file, or load the sample. Pasting, opening a file or loading the sample runs it automatically.

  2. 2

    Keep Compress and Shorten names on for the smallest output. Turn them off for whitespace-only minification.

  3. 3

    Turn on “Keep licence comments” to preserve /*! … */ and @license banners.

  4. 4

    Press Minify. The status bar shows the size before and after.

Examples

1Minify a small function
Before
function greet(name) {
  return "Hello, " + name;
}
console.log(greet("Ada"));
After
function greet(e){return"Hello, "+e}console.log(greet("Ada"));

Good to know

  • TypeScript and JSX must be compiled to plain JavaScript first.
  • “Shorten names” only renames local variables; global names and object properties are kept so your code keeps working.
  • No source map is produced.

Frequently asked questions

Which minifier does this use?

Terser, the open-source minifier used by tools such as Vite and webpack.

Will minified code behave the same?

It should, as long as the code does not depend on function names or on code that Terser considers unused. Always test minified output before shipping it.

Is my code uploaded to a server?

No. Processing happens entirely in your browser, in a background thread. Your input is never sent to our servers or stored anywhere.

More tools that pair well with this one.

Browse all tools