Code Minifier — Free JS, CSS, HTML
Minify JavaScript, CSS, or HTML to reduce file size for production. Strip whitespace, shorten variables, remove comments — all in your browser, no upload.
How to minify JavaScript, CSS, or HTML in your browser
- Pick the language. Choose JavaScript, CSS, or HTML from the language tabs. Each uses a language-specific minifier under the hood (Terser for JS, csso for CSS, html-minifier-terser for HTML).
- Paste your code. Paste source code into the left editor. Drag a file in if you prefer. Up to ~5 MB processes smoothly in-browser.
- Pick a minify level. Basic = strip whitespace and comments only (safe, reversible). Aggressive = also shorten variable names, inline constants, and apply dead-code elimination. Use Basic for debugging-friendly output, Aggressive for production.
- Copy the minified output. See live size reduction (typical: 30–70% smaller). Copy the result with one click, or download as a .min.js / .min.css / .min.html file.
Frequently Asked Questions
- Is my code uploaded to a server?
- No. Minification runs entirely in your browser. Your source code never leaves your device — important for proprietary or pre-release code.
- How much size reduction should I expect?
- Typical: JS shrinks 50–70%, CSS shrinks 20–40%, HTML shrinks 15–30%. Code with verbose comments and long variable names compresses most. Already-minified code shows little improvement.
- Does it support modern JavaScript (ES2022, ESM, async/await)?
- Yes. The Terser-based JS minifier handles the full modern JS spec — classes, ES modules, top-level await, optional chaining, decorators, and more.
- Can it generate source maps?
- Yes. Toggle "generate source map" to get a .min.js.map alongside the minified file. Source maps let DevTools show original line numbers when debugging the minified bundle.
- Will aggressive mode break template literals or eval?
- Template literals are preserved exactly. Code that uses eval() or Function() with strings referencing local variable names cannot be safely renamed — use Basic mode for that.
- What browsers does the output target?
- Default target is "modern" (last 2 versions of Chrome, Firefox, Safari, Edge — covers ~95% of users). You can switch to "ES2015" for broader compatibility (kept in for legacy enterprise users).
Use Cases
- Shrink an inline <style> block before sending an HTML email
- Minify a one-off script for production deployment
- Compress a CSS file before deploying to a CDN
- Optimize JavaScript for an embedded widget or library
- Reduce file size for low-bandwidth deployment (mobile, kiosk, IoT)