Free text tools — updated for 2025 | All Text Tools

JavaScript Minifier

Remove comments and collapse whitespace to shrink JS files. Optionally strip console.log calls before shipping to production.

JavaScript Minifier

What this minifier does

  • Removes single-line comments — strips // … comments while being careful not to touch URLs inside strings
  • Removes block comments — strips /* … */, optionally preserving /*! … */ license headers
  • Collapses whitespace — multiple spaces, tabs, and newlines are reduced to a single space. Newlines required for ASI safety are preserved.
  • Removes console.* — optionally strips console.log(), console.warn(), etc. for production builds
  • Beautify mode — adds line breaks after ;, {, } and indents blocks for human readability. Useful for reading minified third-party code.

Note: This tool does not rename variables, inline constants, or perform dead-code elimination. For production use, consider build-time tools like esbuild, Terser, or Rollup which do full AST-based optimisation. This tool is great for quick minification of small scripts or making minified code readable.

Frequently Asked Questions

This minifier only removes comments and collapses whitespace — it does not rename identifiers, change syntax, or reorder code. As long as your JavaScript doesn't use ASI edge cases (lines that begin with [, (, /, +, or - where a semicolon is implicitly needed), it will work identically. If you're unsure, test the output in your browser's console before deploying. For complex codebases, use Terser or esbuild which have test suites specifically covering these edge cases.
Comment and whitespace removal alone typically gives 10–25% reduction for well-commented code, or almost nothing for already-compact code. Full minification with variable renaming (Terser/esbuild) can reduce files by 50–70%. However, gzip compression (which all modern web servers apply) is the biggest win — a 200 KB file often gzips to 60 KB regardless of minification. The combination of minification + gzip is most effective: minified code has fewer unique tokens, which compresses even better.
Only if the console call has no important side effects in its arguments. For example, console.log(incrementCounter()) would be unsafe to remove if incrementCounter() has side effects beyond logging. In practice, most console.log calls just pass simple variables or string literals and are safe to strip. The "Remove console.*" option here uses a simple regex and removes the entire statement — it doesn't parse the arguments. If you're unsure, leave this unchecked and handle it at build time with a linter rule or Terser's drop_console option.