Last updated ·Published ·By the WiserWork team
JavaScript Minifier
Minify JavaScript by removing comments, whitespace & shortening code
This JavaScript Minifier strips comments and whitespace with regular expressions, and offers a rough variable-renaming option that is nothing like the mangler in a real build tool.
What is the JavaScript Minifier?
Serious minifiers such as Terser parse your code into a syntax tree, work out which names are safe to rename inside each scope, then print the tree back out. This tool does not parse anything. It applies a list of regular expressions: it deletes comments, squeezes the spaces around braces, parentheses, commas, operators and colons, and optionally strips console calls. The Shorten Variable Names checkbox does exist, but it is a blunt find-and-replace, not scope-aware renaming.
Key Features
- Deletes line and block comments, then collapses spacing around operators
- Optional console.log, warn, error, info and debug removal
- Optional naive renaming of up to 26 declared variables to single letters
- Character counts for the original, the output and the percentage saved
- Copy, download as script.min.js, or swap the panes to compare
Common Use Cases
- Trimming a small standalone script before dropping it into a static page
- Removing debug console calls from a snippet you are about to hand over
- Seeing roughly how much of a file is comments before a code review
- Compacting a bookmarklet or short inline handler that must fit one line
How to Use the JavaScript Minifier
- Paste your script over the sample cart calculation in the left pane.
- Keep Remove Comments and Remove Whitespace checked, then read the output pane.
- Tick Remove console.log if you want the debug calls stripped as well.
- Leave Shorten Variable Names off unless you will test the result thoroughly.
- Run the minified file yourself, then click Download .min.js to save it.
Tips for Best Results
- Comment removal deletes everything after a double slash, including one inside a quoted URL string
- Shorten Variable Names replaces matching text anywhere, so it also hits object keys and strings
- The console remover misses calls whose arguments contain their own parentheses, leaving a stray bracket
- For production bundles use Terser or esbuild, which parse the code instead of pattern-matching it
Why Use WiserWork's JavaScript Minifier?
For a fifty-line script living in a static page, running a build tool is more effort than the file is worth, and this does the obvious part in a text box. The honest limit is that pattern matching cannot tell code from the inside of a string, so anything unusual needs testing before it ships. Treat the output as a draft you verify, not a build artifact you trust blindly.
Who Uses the JavaScript Minifier?
Hobbyists and static-site maintainers who write plain script tags rather than modules get the most out of it. It also suits teachers and students who want to see what minified code actually looks like, and anyone stripping console noise from a snippet before sharing it.
Frequently Asked Questions
Does this minifier rename my variables?
Only if you tick Shorten Variable Names, and even then it is crude. It collects the first name after each var, let or const, maps up to 26 of them to single letters, and replaces every matching word in the file.
Why is that renaming risky?
Because it is not scope-aware. A property called total, or the word total sitting inside a string, gets renamed along with the variable, and a name that is already a single letter can collide with a new one.
How is this different from Terser or UglifyJS?
Those parse your code into a syntax tree and rename only what is provably safe within each scope. This tool runs regular expressions over the raw text and never builds a tree at all.
Will it break a URL written inside a string?
It can. Comment removal deletes from a double slash to the end of the line, and the double slash in an https address matches that pattern exactly.
What does the console removal actually match?
Calls to console.log, warn, error, info or debug whose arguments contain no closing parenthesis. A call that wraps another function call is only partly removed, leaving a stray bracket behind.
Does it handle template literals and regular expressions safely?
Not reliably. Spacing inside backtick templates gets collapsed like any other text, and a slash in a regex literal can look like the start of a comment.
How much size reduction should I expect?
Comment-heavy source often drops 30 to 50 percent by character count. Code that was already dense will barely change, and the counters under the panes show the real figure.
Is my code sent to a server?
No. The whole minifier is JavaScript running inside this page, so whatever you paste stays in the tab and disappears when you close it.
Can I recover the original from the output?
No. Comments and formatting are deleted rather than mapped, and no source map is produced. Keep your readable file as the working copy.
Should I minify during development?
No. Minify only at the point of deployment. Debugging minified code without a source map wastes far more time than the saved bytes are worth.
Used as a whitespace and comment stripper on a small script, this does the job in a second. Used as a mangler it will eventually bite you, so test the output or reach for a real build tool.