Code tool
JavaScript Minifier
Paste JavaScript and minify it into a smaller file that behaves the same.
Runs entirely in your browser. Nothing you paste is uploaded.
Paste some JavaScript to get started.
How to use the JavaScript Minifier
- Paste your JavaScript into the left box, or load the sample.
- Choose the options you need, then select Minify.
- Copy the result or download it as script.min.js.
How JavaScript minification works
A JavaScript minifier makes a script smaller without changing what it does. This online JS minifier uses Terser, the engine most build tools rely on, so you can minify JS without setting up a project.
This tool runs Terser, the minifier used by most build tools. It parses your code, so it understands modern syntax such as arrow functions, classes, optional chaining and async functions, and it reports syntax errors with the line and column.
Compress removes unreachable code and simplifies expressions. Shorten local variable names renames variables inside functions to one or two letters. Names at the top level are kept, so other scripts can still call your functions. Turn on ES module for files that use import or export, so unused top-level code can be removed and top-level names shortened too.
Minified code is typically 40 to 70 percent smaller. Keep your original source: minified code is hard to read and debug. The minifier itself is only downloaded when you first press Minify.
Common questions
How do I minify JavaScript online?
Paste the code and the minifier returns the compressed version, ready to copy into your file.
Will minified code still work?
Yes. Terser keeps the behaviour the same. Code that depends on function names or on reading its own source text is the rare exception.
Why did I get a syntax error?
The parser found code it could not read. The message shows the line and column, and the position is selected in the input box.
Does it support TypeScript or JSX?
No. Compile those to JavaScript first, then minify the output.
Is my code uploaded?
No. Terser runs in your browser, so your code never leaves your device.
Guides for the JavaScript Minifier
- How to Minify JavaScript: What Minification Does and WhyMinifying JavaScript removes whitespace and dead code and shortens names, so scripts download and parse faster. How it works and how to do it.
- Async vs Defer: How to Load JavaScript Without Blocking the PageAsync vs defer explained with a timeline: how each script attribute changes loading and execution order, which to use when, and what type=module does.
- What Is JavaScript? A Beginner's Guide to the Language of the WebWhat JavaScript is, what it does on a web page and how it works with HTML and CSS, with short examples you can run in your browser right away.
- How to Format and Minify HTML (Without Breaking the Page)Format HTML so it is readable, or minify it so the page is lighter. Which whitespace matters, what a safe minifier removes, and how to do both.