JavaScript Minifier
Minify JavaScript with terser — safe AST-based compression & name mangling that never breaks strings, URLs or regex. Live, with precise errors and compression stats.
About this ToolHow it works, benefits & use casesTap to collapse
Shrink JavaScript for production using terser, the AST-based minifier behind most modern build pipelines. Because terser parses your code into a real syntax tree instead of hacking at it with regular expressions, it never corrupts strings, URLs, or regex literals — the protocol slashes in a URL and the slashes in /https?:\/\//g survive intact. Two toggles control how aggressive it gets: Compress applies dead-code elimination and expression folding, while Mangle names shortens local variable and function names to single letters. The minified output regenerates live as you type, and a compression panel breaks down the original bytes, minified bytes, bytes saved, and the percentage saved. Syntax errors are reported with a line, column, and a caret code-frame snippet. Everything runs in your browser — your code is never uploaded.
How to Use
- 1Choose your options: Compress for dead-code elimination and expression folding, and Mangle names to shorten local identifiers.
- 2Paste your JavaScript into the input box, or click Load example to load a sample with a URL and regex literal.
- 3The minified output regenerates live, with a byte count and savings percentage shown on the output panel.
- 4Press Minify JavaScript to confirm; any syntax error appears with its line, column, and a caret code-frame.
- 5Review the compression panel for original, minified, saved bytes, and percentage saved.
- 6Copy the minified code, download it as minified.js, or share the URL with your input and options encoded in it.
Key Benefits
- AST-based minification with terser — never breaks strings, URLs, or regex literals
- Compress option performs dead-code elimination and expression folding
- Mangle option shortens local variable and function names for smaller output
- Compression panel reports original, minified, saved bytes, and percentage saved
- Syntax errors reported with line, column, and a caret code-frame snippet
- Live minification as you type, with a shareable URL capturing your options
- Runs entirely in-browser — your source code is never uploaded
Common Use Cases
- Producing a smaller production build of a script for faster page loads
- Minifying a standalone snippet or widget before embedding it on a site
- Comparing compression results with Mangle or Compress turned on and off
- Quickly checking how many bytes a refactor saves before bundling
- Minifying code that contains tricky regex or URL literals safely
Options
Dead-code elimination, expression folding
Shorten local variable / function names
0 characters · live
Paste JavaScript above to minify it live.
Was this tool helpful?
Share Your Experience
Help others discover this tool!
Related tools
A regex minifier blindly strips whitespace and comments, which can mangle string contents, URLs, or regular-expression literals. Terser parses your JavaScript into an abstract syntax tree and regenerates it, so it understands what is code and what is data — the slashes inside a URL or a regex literal are preserved exactly.
Compress applies optimisations such as dead-code elimination and folding constant expressions, reducing the structure of the code. Mangle shortens local variable and function names to short identifiers. You can enable either or both; both are on by default for the smallest output.

