JavaScript Minifier

Compress JavaScript Code Instantly

Need to use JavaScript Minifier right now?

Useful for a quick script you're embedding directly in an HTML page without a full build pipeline.

No sign-upNo uploads 100% free

7249 characters (32% smaller)

function greet(name){console.log('Hello,'+name);}

Strips comments and collapses whitespace — a safe textual minifier, not a full parser-based minifier like Terser.

Features

  • Runs entirely in your browser
  • Privacy-first — your data is never uploaded
  • Real-time, instant results
  • 100% free, no sign-up required
  • Works on desktop, tablet, and mobile
  • No installation needed

Who uses this tool?

Software engineersWeb developersAPI testersDevOps engineersStudents

About JavaScript Minifier

JavaScript written for readability has comments, indentation, and line breaks that all add bytes without changing behavior — this tool strips them out to shrink the file, while being careful not to touch anything inside string or template literals, where a `//` or `/* */` sequence is actual content, not a comment.

The minifier walks through the code character by character, correctly tracking when it's inside a single-quoted, double-quoted, or backtick template string, so comment-stripping never accidentally corrupts a URL or regex pattern that happens to contain `//`. Once comments are removed, remaining whitespace and line breaks collapse down to a compact single-line result.

This is a safe, textual minifier rather than a full AST-based minifier like Terser or UglifyJS — it won't rename variables to shorter names or perform dead-code elimination, but it removes comments and whitespace without any risk of breaking string content, which is the failure mode naive minifiers hit most often.

How it works

  1. Paste your JavaScript. Any readable, commented source code.
  2. Comments and whitespace strip automatically. String content is correctly preserved untouched.
  3. Copy the minified result. See the size reduction percentage live.

Examples

Minifying a small function

Input

function greet(name) {\n  // say hello\n  console.log('Hi ' + name);\n}

Output

function greet(name){console.log('Hi '+name);}

Frequently asked questions