Free JavaScript Minifier
Strip comments and collapse whitespace in JavaScript, entirely in your browser.
This is a lightweight, comment-and-whitespace minifier (not a full parser like Terser) — it never renames variables or rewrites logic, and it leaves strings, template literals, and regexes untouched, so it's safe on code a full minifier's build step doesn't already cover.
How to minify JavaScript
-
1
Paste your JavaScript
Paste formatted or hand-written JavaScript into the input box.
-
2
Click "Minify →"
Comments are removed and whitespace between tokens is collapsed.
-
3
Copy the result
Click "Copy output" to grab the minified code, and test it before shipping.
Example use cases
Shrinking a script with no build step
Cut the size of a standalone script before shipping it when you don't have Terser or a bundler configured.
Stripping comments before sharing code
Remove internal notes and TODOs from a snippet before pasting it somewhere public.
Quick size check
See roughly how much whitespace and comments are adding to a file's footprint.
Frequently asked questions
What does this minifier do?
It scans your JavaScript token by token, drops comments, and collapses the whitespace between the remaining tokens down to what's needed — without renaming variables or restructuring logic.
Is this the same as Terser or a build-tool minifier?
No. Real minifiers also rename variables, remove dead code, and shorten expressions, which needs a full parser and carries more risk. This tool only removes comments and whitespace, so the output is easy to reason about and safe to spot-check.
Will it break my strings, template literals, or regex?
It's designed not to — the tokenizer tracks whether it's inside a string, template literal, or regex literal and passes that text through completely unchanged.
Is my code uploaded anywhere?
No. Minifying happens locally in your browser using JavaScript — nothing you paste is sent to a server.