JavaScript Minifier & Beautifier
Minify JavaScript for production, or beautify minified/compressed JS back into readable code.
How to Use
- Paste your JavaScript into the input box.
- Click "Minify" to compress for production.
- Click "Beautify" to expand minified code for reading or debugging.
- Copy or download the result.
When to Use This
- Shrinking a small standalone script for a page with no bundler, where setting up a build toolchain for one file is overkill.
- Re-indenting a minified third-party widget so you can read what it does before deciding whether to include it on a page.
- Reformatting a snippet from a bug report where the reporter pasted the whole thing onto a single unreadable line.
- Collapsing a short helper function into one line for a bookmarklet or a console paste, where line breaks get in the way.
Frequently Asked Questions
About This Tool
Minifying JavaScript is a different job from compressing it and different again from obfuscating it. The hard part is that newlines are sometimes syntax: automatic semicolon insertion ends a statement at a line break in certain positions, so a file written without semicolons means something else once the line breaks are gone. Production minifiers avoid this by parsing to a syntax tree and printing it back, which also lets them rename local variables and drop unreachable code.
This tool is a tokenizer rather than a parser. It walks the source splitting it into strings, template literals, comments and ordinary code, so nothing inside a quoted string is ever rewritten. Comments are dropped, runs of spaces in the code spans are collapsed, spaces around punctuation are removed and newlines are deleted. The beautifier reverses the layout, re-indenting two spaces per brace level. Both report the character count before and after.
Notes & Limits
- Newlines are removed, so source relying on automatic semicolon insertion rather than explicit semicolons will break. Run it past a linter first.
- Identifiers are never renamed and dead code is never removed, so the saving is much smaller than Terser or esbuild would achieve.
- Spaces around operators are stripped without checking what sits either side, so an expression written as a + +b collapses to a++b and changes meaning.
- The tokenizer knows quotes and comment markers but not regular expression literals, so a pattern containing a quote can be mistaken for a string opening.