UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeCode & DevJS Minifier

Related Tools

JSON FormatterBase64UUID GeneratorJWT DecoderTimestampRegex TesterRandom JSON GeneratorAPI Load TesterJSON Diff CheckerJSON Path FinderSchema ValidatorXML FormatterHTML FormatterCSS FormatterCSS MinifierHTTP Status CodesASCII Table

JavaScript Minifier & Compressor

Strip comments, collapse whitespace and drop console calls from any script. Keeps strings, regex and template literals intact. Copy or download as .min.js.

You Might Also Like

All Code & Dev

JSON Formatter

Paste raw JSON to instantly format, beautify, validate and minify it. Syntax errors are pinpointed by line and column. Free and fully private.

Base64

Encode text or data to Base64 and decode Base64 strings back to readable text. A fast developer utility for API payloads, tokens and data URIs.

UUID Generator

Generate RFC 4122 compliant UUID v4 strings with one click, or batch-generate up to 100 unique IDs at once. Cryptographically random and free.

JWT Decoder

Decode and inspect JSON Web Tokens. View header, payload, and signature. Detects expiry and maps all registered JWT claims.

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.

Worked Example: Compressing the greet Function

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.

What Each Option Controls

  • Strip comments (default on) removes all // and /* */ comments. A /*! licence banner is always preserved regardless, so attribution stays attached to the minified file.
  • Collapse spaces removes indentation, blank lines and optional whitespace around punctuation. Turn it off when comparing two outputs: comments are still stripped but line structure stays readable.
  • Shorten booleans replaces bare true with !0 and bare false with !1. Both evaluate identically in every JavaScript engine. Leave it off for debug builds.
  • Drop console.* removes every console.log, console.warn, console.error and similar call, arguments included, and reports how many were removed under the output.

Edge Cases and Tricky Inputs

  • Template literals keep all their whitespace, including deliberate newlines inside multi-line strings. Expression slots ${…} are scanned for their closing brace but their contents are not rewritten.
  • Regex literals are protected once the scanner decides the / 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 […].
  • Unterminated strings stop the minifier entirely and show the message "A double-quoted string cannot span multiple lines." This prevents a partially minified file that silently breaks at runtime.
  • Comment-only input compresses to 0 bytes. The byte counter reads 0 B after and 100.0% saved, which is correct: a file the browser never needs to parse costs nothing to deliver.

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.