Regex vs division
Minifiers must tell /foo/ (a RegExp) from a/b (division). Heuristics look at the token before the slash to decide.
This JavaScript Minifier & Beautifier is a simple, private way to clean up code. It runs entirely in your browser, so nothing you paste is uploaded or shared. Use it when you want to compress code for faster delivery, or when you need to format JavaScript to make it readable again.
Minifying JavaScript means removing parts of the file that humans use but browsers do not need, such as extra spaces, line breaks, and most comments. The goal is a smaller file size and quicker downloads. Beautifying is the opposite: it restores indentation and consistent spacing so the logic is easier to follow. This tool uses a careful tokenizer to avoid changing strings, regular-expression literals, or template literals, which helps preserve behavior while still shrinking or formatting the code.
To use the calculator, paste your code into the input box, choose the mode (Minify or Beautify), and set the options you prefer. Then run the tool and copy the result from the output area. For quick workflows, press Ctrl/Cmd + Enter to run Minify. Your last input is kept locally in the browser so you can pick up where you left off.
Options let you control how aggressive the formatting is. For example, you can remove comments to reduce size, keep license banners if you need to preserve legal headers, collapse whitespace for a tighter bundle, and insert safe semicolons in tricky edge cases where JavaScript’s automatic semicolon insertion could change meaning.
Whether you need a JavaScript compressor, a code formatter, or a quick JS beautifier, this tool helps you go from messy or bulky code to clean, readable, or smaller output in seconds.
No. This tool runs entirely in your browser. Nothing is sent to any server.
It’s intentionally conservative for safety and privacy. It removes comments/whitespace and preserves behavior, but does not perform advanced AST transforms or mangling.
Yes — enable “Keep /*! ... */ license banners” to preserve license comments.
Minifiers must tell /foo/ (a RegExp) from a/b (division). Heuristics look at the token before the slash to decide.
Automatic Semicolon Insertion works, but edge cases (return then newline then /regex/) can bite. Safe minifiers add semicolons in risky spots.
Comments starting with /*! … */ are often licenses. Minifiers keep them when you enable the option, dropping the rest for size.
Less whitespace means smaller bundles before gzip/brotli, which makes compression ratios even better.
Pretty-printing can expose dangling braces or mismatched indentation that hide in minified blobs—great before code reviews.