What This Tool Does (And What It Does Not)
This js minifier online strips comments, collapses whitespace, and optionally removes console calls, while carefully preserving string and template literal contents so nothing inside quotes gets corrupted. It is honest about what it is not: unlike Terser or UglifyJS, which parse a full syntax tree to rename variables and eliminate dead code for maximum compression, this tool works at the text level, so it produces a smaller, safer, still-readable result rather than the smallest possible bundle. If you need build-pipeline-grade compression, use Terser, if you need to quickly minify javascript online for a snippet, a script tag, or a one-off file, this tool acts as a fast javascript whitespace remover with zero risk of a renamer breaking dynamic property access.
How to Minify JavaScript With This Tool
Paste your JavaScript into the input field to minify js code online, toggle which options you want to remove comments from javascript, collapse whitespace, or remove console calls, and the minified output appears immediately along with the original size, the minified size, and the percentage saved. Copy the result directly, it is valid, executable JavaScript, just smaller and without the extras you chose to strip.
What Gets Removed vs. What Gets Preserved
Both block comments and line comments are removed when that option is on. Console calls, log, warn, error, info, debug, and trace, are removed only if you explicitly enable that option, since they are sometimes intentional. String literals and template literals, including ones that span multiple lines, are located and preserved before any whitespace collapsing happens, so a comment-like sequence or extra spacing inside a string is never touched.
Lightweight Minifier vs. a Full Build-Tool Minifier
A lightweight, text-based javascript minifier free of any build step is the right choice for quickly shrinking a standalone script, cleaning up a code sample before sharing it, or stripping debug logging before a quick deploy. A full build-tool minifier like Terser, integrated into webpack, esbuild, or Rollup, is the right choice for production bundles where every byte matters and the build pipeline can safely rename local variables and remove unreachable code. The two are complementary, not competing, use this tool for fast, safe, one-off minification.
Common Use Cases
Trimming a JavaScript snippet before pasting it into a forum post or documentation, removing console.log statements left over from debugging before sharing code, needing to compress javascript file content for a static page without setting up a bundler, and comparing before and after byte size to see how much comments and formatting were actually costing are all common reasons to reduce javascript file size with a js compressor online like this one.