How to use the JavaScript Minifier
- 1. Paste your JavaScriptPaste a script, a module or a few functions.
- 2. Choose optionsKeep /*! licence */ comments if your libraries need them.
- 3. MinifyCopy the result or download script.min.js and see the saving.
How it stays safe
The minifier splits your code into tokens, the way a JavaScript engine does, so it knows the difference between a / that divides and one that starts a regular expression, and never touches text inside strings or template literals. It removes comments and spaces, but keeps a line break wherever automatic semicolon insertion might depend on it, so code written without semicolons still works. It does not rename variables or rewrite code, which keeps the output readable in error messages. Your code is processed in your browser and never uploaded.
We checked it on more than 70 files, including Chart.js, jsPDF, html2canvas, PapaParse and d3, our own tool bundles and 23 tricky snippets: every minified file produced exactly the same syntax tree as the original when parsed with the Acorn parser.
Worked example
The sample has two comments, an arrow function with a template literal, a regex test and lines without semicolons. Minified, it goes from 366 B to 274 B, 25.1% smaller, in 6 lines. function add(a, b) { return a + b; } becomes function add(a,b){return a+b;}, the template literal `Hello, ${name}!…` keeps its spaces, and the lines let count=0 and count++ stay on separate lines, because joining them would change the meaning.
Good to know
- For the smallest files, a build tool such as Terser also shortens variable names; use it in production pipelines.
- Minified code is hard to debug, so keep the original and, in larger projects, a source map.
- Code must be valid JavaScript; unclosed strings or comments are reported instead of minified.
Frequently asked questions
Does it support modern JavaScript?
Yes: ES modules, classes, async/await, optional chaining, private fields and BigInt all pass through.
Why are some line breaks kept?
Where removing a line break could change how semicolons are inserted, the minifier keeps it.
Is the JavaScript minifier free?
Yes. You can open the JavaScript minifier, paste code and change every setting without signing up. When you minify JavaScript for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.