Developer Tools
JS Minifier
Minify JavaScript in your browser. Strip comments, collapse whitespace, and tighten punctuation safely. Strings, templates, and regex literals are preserved.
JavaScript minifier
Optimization options
Statement-level line breaks are preserved so automatic semicolon insertion (ASI) cannot change the meaning of the output. Strings, template literals, and regex literals are passed through verbatim.
Your JavaScript is minified entirely on your device. Nothing is uploaded.
How to use
- Paste your JavaScript into the input area on the left, or click Load sample to try the minifier on an example file.
- Toggle the optimization options on the right: remove comments, preserve /*! important comments, collapse whitespace, collapse blank lines, and tighten punctuation.
- Read the minified output on the right with live byte size, savings, and reduction percentage. The output updates as you type or change options.
- Click Copy JS to copy the minified code, or Replace with minified to load the result back into the input for another pass.
About this tool
JS Minifier is a browser-based JavaScript minifier built around a state-machine tokenizer that knows the difference between code and literal data. Strings (single, double, and backtick), template literal expression bodies, regex literals (with full character-class and flag support), and line and block comments are each detected as separate tokens, so the optimizer never touches the inside of a string, a template, or a regular expression. The minifier is intentionally conservative: by default it strips comments (optionally preserving important comments that begin with /*!), collapses runs of intra-line whitespace into a single space, collapses runs of blank lines, trims leading and trailing whitespace on every line, and tightens spaces around safe punctuation (parentheses, brackets, braces, commas, semicolons, and colons) but only where doing so cannot merge two identifier characters. Crucially, statement-level line breaks are preserved so the engine's automatic semicolon insertion (ASI) cannot change the meaning of the output. That is the difference between a safe minifier and a destructive one: a naive 'strip all whitespace' approach can turn a return on its own line followed by an object literal on the next line into a return of undefined, but this tool keeps the structural newlines intact. Toggle each optimization independently to balance file size against readability, use the live byte counter and reduction percentage to see how much you saved, and copy the result with one click. Useful for shrinking inline script tags, bookmarklets, GitHub Pages widgets, JSFiddle and CodePen exports, embed snippets, and any quick production copy where pulling in a full build toolchain is overkill. Everything runs locally in your browser using built-in tokenizer logic, so the source code you paste here, including any API keys or proprietary algorithms, never leaves your device.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
CSS Minifier
Compress CSS with comment, whitespace, hex, and zero-unit optimizations and a live byte-savings readout.
Open tool
DeveloperHTML Minifier
Compress HTML safely: collapse whitespace, strip comments, drop attribute quotes, shrink boolean attributes.
Open tool
DeveloperJSON Minifier
Compact JSON with live byte savings and a JS literal copy.
Open tool
DeveloperSQL Formatter
Pretty print SQL with configurable keyword case, indent, and comma style.
Open tool
DeveloperCSS Formatter
Beautify minified CSS with indent, brace style, and sort options.
Open tool