JavaScript Minifier
Minify JavaScript locally with Terser parsing and conservative output, without executing code, bundling or tree-shaking.
Your JavaScript
Up to 256 KiB measured as UTF-8. Processing runs in a disposable local Web Worker.
Terser parses and prints without executing your code. Compression and mangling are disabled. Not a bundler, transpiler, tree-shaker or TypeScript/JSX compiler. Libraries load from this site only when you run the tool.
Minified output
Understand your results
For developers reducing the presentation size of a JavaScript source file without running it.
Terser parses JavaScript and prints compact code with compression and name mangling disabled. This conservative configuration preserves names and avoids aggressive program rewrites. Strings, regex literals, template literals, automatic semicolon insertion and comments are handled by the parser/printer, not regex replacements. User code remains data; it is never evaluated, imported as a module or inserted into a script element.
How to use this tool
- Paste JavaScript and select Classic script or ES module to match the source.
- Run Minify JavaScript. A local worker loads Terser on demand and returns output or a parsing error.
- Review measured byte sizes, copy/download the .js file and test it in the actual application before replacing production code.
What the observations mean
The parser/printer removes presentation overhead while retaining program names and conservative semantics for supported syntax. It does not execute runtime branches, discover dependencies, prove correctness or measure browser execution speed.
Worked example
Keep a template literal and regex literal distinct from a removable source comment.
function greet(name) {
const clean = name.replace(/\s+/g, " ");
return `Hello, ${clean}!`;
}
// ordinary source commentTerser parses the regex, string and template literal, then prints compact code. The ordinary comment can be removed while names are retained. The tool measures both byte counts; it never calls greet or executes any pasted source.
Limits and processing
Terser 5.51.2 with compress:false and mangle:false, no source maps, bundling, tree-shaking, runtime validation, TypeScript or JSX compilation. Maximum 256 KiB UTF-8 and 12 seconds including parser loading. Processing is local in a disposable browser worker; no unsafe execution fallback.
Common problems and practical fixes
- A syntax error includes a line/column
- Check source type and syntax. Compile JSX/TypeScript before using this plain-JavaScript tool.
- Some comments or names remain
- Preservation comments and all identifier names are deliberately retained; aggressive compression and mangling are disabled.
- The worker fails or times out
- Try a smaller sample or verify browser worker support. Parser code loads from this site's static assets; user input is not sent to a backend.
Best practices
Download a candidate build, run your application's own tests and retain source/maps in your normal pipeline. Smaller text is not proof of improved runtime performance.
Practical tips
- This is not a bundler, transpiler, dependency resolver or tree-shaker. TypeScript and JSX must first be compiled elsewhere.
- Licence/preservation comments can remain. Source-map generation and external source loading are not enabled.
- Select the correct source type: module semantics differ from classic scripts. Minification cannot verify runtime globals, DOM availability or application logic.
Frequently asked questions
Practical answers for using the JavaScript Minifier.
Will pasted code execute?
No. A fixed same-origin browser worker runs the parser library, while your source is passed as a string. No eval, Function constructor or user-controlled module import is used.
Does this rename variables or remove unused code?
No. Mangling and compression passes are disabled. Compact printing and safe comment removal are useful without claiming advanced bundling or tree-shaking.
Can larger inputs freeze the page?
Input is capped at 256 KiB UTF-8 and processed off the main thread. A 12-second deadline includes library loading; the worker is terminated on completion, error, clear, edits or navigation. A blocked worker produces an error rather than a main-thread fallback.