JS Minifier

Minify JavaScript by stripping comments and unnecessary whitespace

JavaScript Minifier — Reduce JS File Size by Stripping Comments, Whitespace, and Redundant Characters with Real-Time Size Comparison

  1. Paste your JavaScript source code into the input textarea. The tool accepts any valid JavaScript — from small utility functions to complete application bundles. JavaScript minification is an essential step in the web performance optimization pipeline: by removing all non-functional characters (comments, whitespace, line breaks, redundant semicolons), you can typically reduce file size by 30–60%, which directly improves page load times, reduces bandwidth costs, and lowers Time to Interactive (TTI) metrics for your users. Unlike obfuscators, minification is reversible in principle — it removes formatting but preserves all logic and semantics.
  2. Click Minify to process your code. The tool immediately displays: the original size in bytes/kilobytes, the minified size, and the percentage savings (highlighted in green to show the improvement). The minification process removes: single-line comments (// comment), multi-line comments (/* comment */), leading/trailing whitespace on each line, blank lines, indentation spaces and tabs, spaces around operators and punctuation (where safe), and unnecessary semicolons. The Shorten Variables toggle enables an experimental feature that renames local variables to short names — use with caution as this can break code that relies on variable name reflection.
  3. Review the minified output — it appears as a single compressed line for maximum density. Copy the minified code using the Copy button, then save it with a .min.js extension for use in production. For deployment, rename your HTML script tags to reference the minified version (<script src="bundle.min.js"></script>). If your build process uses Webpack, Vite, Rollup, or esbuild, those tools provide more advanced minification (dead code elimination, tree shaking, scope hoisting) — this tool is ideal for quick minification without a full build pipeline, and for educational purposes to see exactly what minification does to your code. All processing happens in your browser — your source code never leaves your device.

Enable JavaScript to use these tools.