JavaScript Minifier
Shrink JavaScript for production instantly
Original JavaScript
Options
Minified JavaScript
Overview
The JavaScript Minifier strips comments, unnecessary whitespace, and line breaks from your code to reduce file size for production — smaller downloads, faster parse times. Paste readable JS and get compact output instantly, with a live before/after size comparison.
What This Minifier Controls
- •Comment removal: strip both // line comments and /* block */ comments
- •Whitespace collapse: remove unnecessary spaces, blank lines, and line breaks
- •Size comparison: see original size, minified size, and percentage reduction side by side
- •Semicolon normalization: ensure statement separators survive whitespace removal
- •Preserve-comments toggle: keep license headers or important comments when needed
- •Downloadable output: save the minified result directly as a .js file
When You'd Minify JavaScript
- •Shrinking a script before deploying it to production to reduce page load time
- •Preparing a small utility script for embedding inline in an HTML page without bloating it
- •Quickly checking how much a file will shrink before setting up a full build pipeline
- •Minifying a one-off script for a CodePen, gist, or bookmarklet where a build step isn't practical
- •Comparing minified size against a size budget for a performance audit
How to Minify JavaScript
- 1.Paste your JavaScript into the input editor, or upload a .js file
- 2.Decide whether to preserve comments (e.g. license headers) or strip them entirely
- 3.Minified output and the size-reduction percentage appear automatically
- 4.Copy the output or download it as a .js file
- 5.Check the before/after byte count to confirm the size savings before deploying
Edge Cases Worth Knowing
- •This minifier does not rename variables to shorter names or perform dead-code elimination — those require an AST-based tool like Terser for maximum compression
- •String contents and template literals are left untouched; only structural whitespace and comments outside of strings are removed
- •ASI (automatic semicolon insertion) edge cases in unusual code (e.g. lines starting with ( or [) should be tested after minifying, since removing line breaks can occasionally change behavior around ASI
Limitations
- •This is whitespace/comment minification, not full compression — for maximum size reduction (variable renaming, dead-code elimination, tree-shaking), use a build-tool-integrated minifier like Terser or esbuild
- •Minified output loses all readability — always keep your original source under version control
- •Very large files may be slow to process entirely in the browser — for production build pipelines, integrate minification into your bundler instead of a one-off browser tool
Need to Go the Other Way?
If you have minified or compressed JavaScript and need to read or debug it, use the JavaScript Beautifier instead. It restores indentation, line breaks, and consistent formatting so the code is actually readable.