JavaScript Minifier
Minify JavaScript with Terser: removes whitespace and comments, shortens variable names and simplifies code. Runs locally in your browser.
- Free
- No sign-up
- Runs in your browser
About 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 JavaScript Minifier
- 1
Paste your JavaScript, open a .js file, or load the sample. Pasting, opening a file or loading the sample runs it automatically.
- 2
Keep Compress and Shorten names on for the smallest output. Turn them off for whitespace-only minification.
- 3
Turn on “Keep licence comments” to preserve /*! … */ and @license banners.
- 4
Press Minify. The status bar shows the size before and after.
Examples
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Ada"));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
Is minifying the same as compressing JavaScript?
People use both words for the same job: making a .js file smaller without changing what it does, by removing spaces, line breaks and comments and shortening names. Gzip or Brotli compression on your web server is a separate, extra step that works on top of minified code, so use both.
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.