JavaScript Minifier
Minify JavaScript with Terser.
About the JavaScript Minifier
Minifies JavaScript with Terser, the same minifier most bundlers use. It removes comments and whitespace, shortens variable names inside functions, and folds expressions it can prove, so the result is meaningfully smaller than stripping whitespace would give you. Handy for a one-off script, an inline snippet, or a file that never goes through a build. Terser runs in the page, so proprietary source stays local.
How to use the JavaScript Minifier
- Paste your JavaScript into the input panel, or press Sample to load an example.
- Press Minify.
- Copy the result, or Download it as script.min.js.
Frequently asked questions
- Does minifying change what my code does?
- It should not. Terser's default transforms preserve behaviour for ordinary code. The exception is code that reads names at runtime, such as Function.prototype.name or a dependency injector that inspects parameter names, because local names get renamed.
- Are my top-level variable names renamed?
- No. By default Terser leaves top-level names alone, since other scripts may reference them. Only names declared inside functions are shortened.
- What happens if my code has a syntax error?
- Minification stops and you get the parser's message naming the token it choked on. Terser has to parse the whole file, so it doubles as a syntax check.
- Is minifying the same as obfuscating?
- No. Minified code is smaller and unpleasant to read, but it is still your logic in plain JavaScript and it can be reformatted. Never treat it as protection for a secret.
- Is my source uploaded?
- No. Terser is JavaScript itself and runs inside the page; there is no backend.
Related tools
- JavaScript FormatterBeautify JavaScript code.
- CSS Beautify & MinifyFormat or minify CSS stylesheets.
- HTML FormatterBeautify and format HTML markup.
- JSON FormatterBeautify, minify, and validate JSON instantly.
- SQL FormatterFormat SQL queries for readability.
- XML FormatterFormat and beautify XML documents.