JavaScript Minifier
100% PrivateDeveloper ToolsMinify JavaScript in your browser by removing comments and unnecessary whitespace.
Runs entirely in your browser. Your input is not uploaded to Ovatly or anywhere else.
- 1Paste your JavaScript into the input box.
- 2Press Minify JavaScript.
- 3Check the size report to see the saving.
- 4Copy or download the minified code.
Input: const url = "https://example.com//not-a-comment"; // real comment const x = 1; Output: const url="https://example.com//not-a-comment";const x=1; The // inside the string survives, because it is data, not a comment.
- This is a whitespace and comment minifier, not an optimizing compiler: it does not shorten variable names, remove dead code or bundle modules. For production builds, a tool like terser in your pipeline goes further.
- Template literals are preserved verbatim, including the expressions inside them, so they are never reshaped.
- Unterminated strings, template literals, block comments or regular expressions are reported as errors instead of being silently mangled.
- Regex literals after a closing brace of a block are treated as division, a rare ambiguity every lightweight tokenizer has to resolve one way.
The tokenizer is conservative: it only removes comments and whitespace that cannot change meaning, and preserves statement newlines so automatic semicolon insertion behaves as before. Still, run your test suite after minifying anything important.
About this tool
The JavaScript Minifier removes comments and unnecessary whitespace from JS code in your browser. Unlike a naive find-and-replace, it tokenizes the code first, so text inside strings, template literals and regular expressions is never mistaken for a comment, and newlines that JavaScript's automatic semicolon insertion depends on are kept.
Related tools
Part of Ovatly's free tools in Developer Tools.