JavaScript Minifier
Minify JavaScript in your browser and strip comments and whitespace safely, without renaming a thing.
- Original size
- 0 B
- Minified size
- 0 B
- Saved
- 0%
- Status
- Waiting
How it works
Paste JavaScript on the left and the minified version appears on the right instantly. The
minifier tokenises your code the way a JavaScript engine does โ it understands strings,
template literals, regular expressions and comments โ then removes every comment and every
byte of whitespace that the language does not need. Because it is a real tokeniser and not
a pile of regular expressions, a / inside /[^a-z]+/g stays a
regex, spaces inside "Hello, world" stay untouched, and a line break that
JavaScript would turn into a semicolon (automatic semicolon insertion) is kept so your code
keeps working even when you never wrote semicolons.
This is a safe minifier: it never renames your variables and never rewrites
your logic, so the output is still readable, still debuggable, and byte-for-byte equivalent
in behaviour to what you pasted. Expect roughly 20โ50% smaller files for typical commented,
indented source. Options let you keep /*! and @license banner
comments (the default, so you stay compliant with the licences you bundle) or strip comments
only and leave your formatting alone. Unterminated strings, template literals, regexes and
block comments are reported with the exact line number instead of failing silently.
Everything runs in your browser in vanilla JavaScript โ your code is never uploaded, so it
is safe to paste proprietary or client work. No ads, no sign-up, no file size limit beyond
your own device.
Frequently asked questions
How do I minify JavaScript online?
Paste your code into the left box and the minified version appears on the right instantly, together with the original size, the minified size and the percentage saved. Click Copy minified JavaScript or Download .js to take the result away. You can also load a .js file from your device instead of pasting. Everything happens in your browser, so the code is never uploaded to a server.
Does minifying JavaScript break my code?
Not with this tool. It only removes comments and whitespace that JavaScript does not need, and it never renames variables or rewrites your logic. Strings, template placeholders and regular expressions are left byte-for-byte intact, and any line break that automatic semicolon insertion depends on is kept, so semicolon-free code keeps working. If your source has an unclosed string, comment or regex, you get an error with the exact line number instead of broken output.
How much smaller does minifying JavaScript make a file?
For typical hand-written, commented and indented source, expect roughly 20 to 50% fewer bytes; heavily commented files can shrink more. The Saved percentage on the page shows the exact figure for your file. Because this minifier does not mangle variable names, it saves a little less than Terser or esbuild, but the output stays readable and debuggable, and gzip on your server recovers most of the difference anyway.