JavaScript Minifier
Minify JavaScript by removing unnecessary whitespace and comments for a smaller output.
This tool runs entirely in your browser. Your files are never uploaded to a server.
function greet(name){return 'Hello '+name;}What this minifier does
Removes recognized line and block comments, collapses whitespace, and trims space around common JavaScript punctuation. Quoted strings, template literals, and escaped characters are preserved by the character scanner.
How to use it
Paste code, review the output that updates immediately, and copy it when ready. Reset clears the editor; the tool does not create a file or source map.
Important limitations
This is not a JavaScript parser, bundler, compiler, mangler, or standards-aware minifier. It does not rename identifiers, remove unreachable code, combine modules, validate syntax, or understand regular-expression literals and automatic semicolon insertion. Comment-like text, regex syntax, or line-sensitive statements can be interpreted incorrectly and change behavior.
How the scan works
A left-to-right character scan tracks whether it is inside a string, template literal, or comment; recognized `//` and `/* */` comments are dropped entirely once the scan confirms they are not inside quotes.
Example
Pasting `function add(a, b) { // sum return a + b; }` produces `function add(a,b){return a+b;}`, with the comment removed and spacing around punctuation trimmed.
Safe review workflow
Run the minified output through your test suite before deployment, checking any code with regular-expression literals or automatic-semicolon-insertion-sensitive line breaks, since those are the cases most likely to be altered incorrectly.
Safe workflow and privacy
Keep the original and run tests plus a production-grade minifier before deployment. Compare behavior, not only file size. Processing is local in your browser and pasted code is not uploaded.
Frequently Asked Questions
- What does the JavaScript Minifier do?
- Minify JavaScript by removing unnecessary whitespace and comments for a smaller output.
- Does this JavaScript tool change program behavior?
- It only changes layout or removable whitespace. Review minified output before production use when code relies on unusual syntax.
- Is my code uploaded?
- Processing is local and your code is never uploaded.
Related Tools
JavaScript Formatter
Format and indent JavaScript code into a clean, readable structure directly in your browser.
TypeScript Formatter
Format and indent TypeScript code into a clean, readable structure directly in your browser.
YAML Formatter
Format and prettify YAML documents instantly in your browser.
CSS Minifier
Minify CSS by removing unnecessary whitespace and comments for a smaller output.
HTML Minifier
Minify HTML by removing unnecessary whitespace and comments for a smaller output.
JSON Minifier
Minify JSON by removing unnecessary whitespace and comments for a smaller output.