CSS / JS / HTML Minifier Online Free
Paste CSS, JavaScript, or HTML and minify it instantly — whitespace and comments removed, file size reduced. See exact byte savings before and after. No upload, no signup.
CSS / JS / HTML Minifier
How to Minify Code
- 1Select the language — CSS, JavaScript, or HTML — from the dropdown.
- 2Paste your code into the input box.
- 3Click Minify. The tool removes whitespace and comments and displays byte savings.
- 4Click Copy to copy the minified result to your clipboard.
Why Minify?
Every byte transferred between your server and a visitor's browser takes time. Minified CSS and JavaScript files are smaller, so they parse and execute faster. A typical stylesheet can be reduced by 20–40% by minification alone. Combined with gzip compression (applied by most web servers automatically), total file sizes can drop by 70–90% compared to the original source.
For quick one-off tasks — minifying a third-party stylesheet you cannot rebuild, shrinking an HTML email template, or reducing a configuration file — this online tool is the fastest option with no build tooling required.
Minification Tips
Keep Source Files
Always keep your original readable source file. Minified code is not meant for editing. Store the unminified version in version control and serve the minified version in production.
Beautify First If Needed
If you need to inspect minified code you received (e.g., a vendor library), use the JavaScript Beautifier first to make it readable, then minify back if needed.
Use Gzip on Your Server
Minification and gzip compression are complementary. Enable gzip or Brotli on your web server — the combination of minified + compressed files is typically 5–10× smaller than the original source.
Minify HTML Emails
HTML email templates are often bloated. Minifying an email template reduces the raw message size, which is important for email clients that clip messages over a size threshold (Gmail clips at ~102KB).
Frequently Asked Questions
What does minification do?
Minification removes characters from code that are unnecessary for execution: whitespace, indentation, comments, and newlines. The result is a functionally identical file that is smaller in bytes. Smaller files download faster, reducing page load time and bandwidth cost. Minification is a standard step in front-end build pipelines (webpack, Vite, Parcel) before deploying to production.
Is the minified code safe to use in production?
For CSS and HTML, the minified output is always functionally identical to the original. For JavaScript, the tool uses regex-based stripping of comments and whitespace — this is safe for well-formed code without template literals that span multiple lines or regex literals containing comment-like patterns. For complex or framework-bundled JavaScript, a dedicated build tool like Terser (used by webpack and Vite) provides safer AST-level minification.
How is the byte savings calculated?
After minification, the tool counts the UTF-8 byte length of the original and minified strings and displays the before/after sizes and percentage reduction. This matches what would be transferred over HTTP without gzip compression. With gzip (standard on most servers), the savings are typically smaller because gzip already handles repetition efficiently.
Does the CSS minifier handle all CSS features?
The tool handles the most common cases: removing comments, collapsing whitespace, and removing unnecessary semicolons. It does not perform advanced optimisations like merging duplicate rules, shorthand property collapsing, or unused-rule removal. For production CSS, a dedicated tool like cssnano (integrated in PostCSS/webpack) provides more thorough optimisation.
Can I minify TypeScript or JSX?
The JavaScript minifier strips comments and whitespace but does not parse the AST, so it works on TypeScript and JSX as text. However, TypeScript type annotations and JSX are not valid JavaScript and would need transpilation (e.g., via tsc or Babel) before deployment regardless. Use this tool to quickly reduce a file size for inspection, not as a production build step for typed or JSX code.
Is my code sent to a server?
No. Minification runs entirely in JavaScript inside your browser. Your code is never transmitted over the network and is never stored anywhere. The tool works offline once the page has loaded.