Strip comments, collapse whitespace and drop console calls from any script. Keeps strings, regex and template literals intact. Copy or download as .min.js.
Every comment, tab stop, and blank line between functions adds bytes that a browser downloads and discards before reading a single instruction. JavaScript Minifier strips them in a single pass without touching your logic. Paste any script and the compressed version appears underneath with a before/after byte count and a progress bar.
JavaScript is harder to compress than CSS because the same character can mean three different things depending on context: a / after a closing parenthesis is division, after = it opens a regex literal, and after console.log it starts nothing at all. The scanner tracks the last non-whitespace token to decide, keeping string contents and regex bodies inside sentinels no later pass sees.
Press Load Sample and the first script loaded is:
function greet(name) {
console.log("Hi, " + name);
return name.length;
}
greet("Aria");With default options the output is:
function greet(name){console.log("Hi, "+name);return name.length;}greet("Aria");Indentation, the blank line between the function body and the call, and spaces around the + operators are removed. The string content "Hi, " is untouched because the quotes place it behind a sentinel before any space pass runs.
// and /* */ comments. A /*! licence banner is always preserved regardless, so attribution stays attached to the minified file.true with !0 and bare false with !1. Both evaluate identically in every JavaScript engine. Leave it off for debug builds.console.log, console.warn, console.error and similar call, arguments included, and reports how many were removed under the output.${…} are scanned for their closing brace but their contents are not rewritten./ is not division. A character class like [^/\n] containing a forward slash does not end the pattern early because the scanner tracks whether it is inside […].Options
Paste a script, or press Load Sample
Comments, indentation and redundant whitespace are stripped entirely in your browser. Nothing is sent to any server.