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.
72 → 49 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?
People also search for
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
- Paste your JavaScript. Any readable, commented source code.
- Comments and whitespace strip automatically. String content is correctly preserved untouched.
- 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);}