Compress your JavaScript to reduce file size and improve page speed — or beautify minified JS back into readable code. Paste or upload a file. Safe tokenizer that preserves strings & regex. 100% free.
JavaScript minification is the process of removing all characters from JS source code that are not required for execution — whitespace, comments, newlines, and sometimes long variable names. The resulting file works identically in the browser but is smaller, which means it downloads faster, parses faster, and contributes to a better user experience and higher PageSpeed scores.
Minification is a standard step in every modern web development workflow. Whether you are building a small custom script or a complex React application, your production JavaScript should always be minified before deployment.
Many simple JS minifiers use regular expressions to strip whitespace and comments. This approach is dangerous: a naive // comment remover will also destroy URLs like https://api.example.com inside string literals. Similarly, stripping spaces around all operators can corrupt template literals, regex patterns, and string concatenations.
This tool uses a proper character-by-character tokenizer. It identifies and preserves string literals ('...', "..."), template literals (`...`), and regex literals (/pattern/flags) completely untouched, and only removes comments and collapses whitespace in actual code regions.
// comment lines from your code. Safe to remove in production — they are developer notes only.
/* ... */ blocks. In heavily documented code these can account for 10–30% of the file size.
/*! ... */ blocks (starting with !). Many open-source libraries use this convention to mark copyright notices that must be kept even in minified builds.
console.log(), console.warn(), console.error() and other console method calls — debug statements you don't want in production.
debugger; statements that pause execution in browser DevTools. These should never ship to production.
Minification removes unnecessary characters from a single file to reduce its size. Bundling combines multiple JS files into one to reduce the number of HTTP requests. Both are done in production — typically bundling happens first (with webpack, Vite, or Rollup), then each bundle is minified. This tool handles minification of individual files.
Use a caching or performance plugin: WP Rocket, LiteSpeed Cache, W3 Total Cache, and Autoptimize all include JavaScript minification options. For custom scripts you've added, you can paste them here, minify, and re-upload. Always test after enabling plugin-based JS minification — aggressive settings can occasionally break themes or plugins.
Minification removes whitespace and comments. Uglification (mangling) goes further and renames local variables and function parameters to short single-character names (a, b, c...) to squeeze out even more bytes. Mangling requires a full abstract syntax tree (AST) parser — it cannot be done safely with simple text processing. Tools like Terser and UglifyJS do this as part of a build pipeline.
Yes — if you plan to debug production issues. Source maps are separate .map files that map minified code back to the original source. They are not served to regular users but are loaded by browser DevTools when you open the sources panel. This tool produces minified JS only (no source map), so keep your original source files for debugging purposes.
This tool works on plain JavaScript only. TypeScript (.ts) and JSX (.tsx/.jsx) must be compiled to plain JS first (using the TypeScript compiler or Babel) before minification. After compilation, paste the resulting .js output here.