How to use JavaScript Minifier
- Paste your JavaScript into the input box, or click Open a file to load a .js file.
- Keep "mangle" and "compress" on for the smallest output, or turn them off to only remove whitespace and comments. Tick "ES module" for import/export code.
- Read the minified code in the output box, with the size before and after.
- Click Copy or Download to save script.min.js.
Features
- Removes comments and whitespace
- Shortens local variable and function names (mangle)
- Simplifies expressions and removes unreachable code (compress)
- Supports modern syntax and ES modules
- Shows bytes before and after, and reports syntax errors with line and column
- Runs in your browser, so the code is never uploaded
Supported formats and limits
- Maximum input: 10,000,000 characters
Examples
| Input | Result |
|---|---|
| function greet(name) { // say hello const message = "Hello, " + name + "!"; console.log(message); } greet("OneVixa"); | function greet(e){const o="Hello, "+e+"!";console.log(o)}greet("OneVixa"); — 124 bytes → 74 bytes. |
| var a = ; | Could not parse this JavaScript at line 1, column 9: Unexpected token: punc (;) |
Limitations
- Always test minified code. Code that depends on function or variable names, for example through Function.prototype.name or eval, can break when names are shortened; turn mangle off in that case.
- Global names and property names are not renamed.
- The tool does not bundle files and does not produce source maps.
Learn more
JavaScript sent to browsers is usually minified. A minifier removes everything that only helps humans, such as comments, indentation and long names for local variables, and can also rewrite code into an equivalent but shorter form. Smaller files download faster, which matters most on slow mobile connections.
Terser, the engine used here, works in stages. It parses the code into a syntax tree, which is why invalid code is rejected with a location. The compress stage then applies safe simplifications, such as evaluating constant expressions and removing code that can never run. The mangle stage renames local identifiers to short names; names visible outside the file, such as global variables and object properties, are kept.
Minifying is different from obfuscating: the aim is size, not secrecy, and the result can still be read with effort. Use source maps in your build tool to debug minified code.
Frequently asked questions
What does mangling do?
It renames local variables, parameters and functions to very short names like a and n. The code behaves the same but takes fewer bytes.
Is minified JavaScript safe to run?
It should behave like the original. Run your tests on the minified file, especially if you rely on function names or on eval.
Why does it report a syntax error?
The minifier has to parse your code first. The message gives the line and column where parsing stopped, for example a missing bracket or an unexpected token.
Is my code uploaded?
No. Terser runs in your browser.
Sources
Last reviewed: September 30, 2026