JavaScript Minifier
Paste JavaScript, get a smaller version. The minifier strips comments, collapses whitespace, and optionally removes console.* calls. It tracks string and regex boundaries so quoted code and regex literals stay intact. Runs entirely in your browser — no upload, no external service.
How to use the JavaScript Minifier
Paste your JavaScript and click Minify. The minifier walks the source character by character, tracking whether the cursor is inside a string, template literal, regex, or comment. Inside any of those, content passes through untouched. Outside, runs of whitespace collapse, comments are removed, and (if enabled) console.*(...) and debugger; statements are stripped.
Banner-preserve keeps comments that start with /*! (the convention for legal / copyright notices that minifiers should never strip). The stats line shows before/after byte counts and the savings percentage.
About JavaScript Minifier
JavaScript minification is one of the simplest production wins: typical hand-written code shrinks by 30-50% on whitespace and comments alone. Real bundlers (Terser, esbuild, Vite’s built-in minifier) go further with identifier mangling — renaming local variables to single letters — to squeeze another 20-30%. Mangling requires a full AST parse to know which identifiers are safe to rename without breaking external references, which is why production-grade minifiers live inside build pipelines.
This in-browser minifier does the lexical pass: strip what’s definitely safe, leave everything else alone. The output runs identically to the input because the transformations are purely cosmetic. For production builds you want the full AST minifier (Vite, esbuild, etc.); for one-off snippets and quick experiments, lexical minification is enough and works without a build setup.
Common use cases
- One-off optimisation of a script tag in a hand-edited HTML page.
- Embedded scripts in HTML emails or PDFs where every byte matters.
- WordPress theme functions.js — minify before paste.
- CodePen / JSFiddle demo shrinking for sharing.