JavaScript Minifier
Compress JavaScript for production using the same engine modern build tools rely on. Code is parsed properly, so a syntax error is reported with its line instead of producing broken output.
- Runs in your browser
- No sign-up
- Free to use
How to use JavaScript Minifier
- Paste your JavaScript or open a .js file.
- Choose whether to shorten variable names (mangle) and apply code optimisations (compress).
- Select Minify JavaScript.
- Check the size saving, then copy or download the minified code.
JavaScript Minifier features
Powered by Terser
The minifier used by webpack, Rollup and Vite, running in your browser.
Name mangling
Local variables and function parameters are renamed to single letters.
Compression passes
Dead code is removed, constants folded and expressions simplified.
Modern syntax
Understands ES2020+ features including modules, classes, async functions and optional chaining.
Real syntax checking
Invalid code is rejected with the line and column of the error.
Private
Source code is not uploaded.
When to use JavaScript Minifier
- Minifying a small script for a site that has no build pipeline.
- Shrinking a bookmarklet or embeddable snippet.
- Checking how much a library could be reduced.
- Quickly validating that a file parses as JavaScript.
JavaScript Minifier FAQ
What is the difference between compress and mangle?
Compress rewrites code into shorter equivalent forms and removes code that can never run. Mangle renames local variables and parameters to short names. Used together they give the smallest output.
Will minification break my code?
Correct code keeps working. Problems occur only when code depends on function or variable names as strings, for example reading Function.name, or relies on global names that are not actually global. Top-level names are not renamed.
Does it support ES modules?
Yes. Tick the Module option when the code uses import or export so that top-level scope is treated correctly.
Are comments removed?
Yes, except licence comments starting with /*! or containing @license or @preserve, which are kept by default.
Can I minify TypeScript or JSX?
No. Compile to plain JavaScript first. Type annotations and JSX are not valid JavaScript and produce a syntax error.
How JavaScript minifiers work
Unlike a regex-based whitespace stripper, a real minifier parses the program into a syntax tree. That gives it an exact understanding of scopes, so it knows which names are local and can be renamed safely, and which expressions have no side effects and can be removed or reordered.
After transforming the tree it prints the code again using the fewest characters possible: no optional semicolons, shortest number forms, quotes chosen to avoid escapes. On typical application code this removes 40–70% of the file size before gzip. Keep your original source and treat the minified output as a build artefact, since it is not meant to be edited.