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.
⏱ 7 min read · Complete guide below
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).
The Complete Guide to Code Minification
Minification is one of the quiet workhorses of fast websites. Every popular site you visit serves code that has been stripped of everything a browser does not strictly need, shrinking files so pages load faster. It is a simple idea with real impact, but it is also frequently confused with related techniques like compression and bundling. This guide explains exactly what minification does, how it fits into modern build tooling, why it matters for performance, and when a quick online tool is the right choice versus a proper build step.
What Minification Actually Removes
At its most basic, minification deletes the characters that make code readable to humans but are irrelevant to a machine: whitespace, indentation, line breaks, and comments. Your source might space out a CSS rule across several lines for clarity; the browser parses it identically whether it is neatly formatted or crushed onto one line, so the formatting is pure overhead to send over the network. Removing it is completely safe and functionally invisible.
More advanced JavaScript minifiers go further with identifier mangling — renaming long local variable names like calculateTotalPrice to a single letter like t. Because the code behaves the same regardless of what its internal variables are called, this can save substantial space in a large file. Some tools also perform dead-code elimination, stripping out functions and branches that are never reached. This tool focuses on the safe, universal step of removing whitespace and comments; the heavier transformations like mangling are the domain of dedicated build-time minifiers.
Minification, Compression, and Bundling: Three Different Things
These three terms are constantly conflated, but they are distinct steps that stack together. Minification rewrites the code itself into a smaller but equivalent form, and the result is still valid code you could serve directly. Compression — gzip or Brotli, applied automatically by most web servers — is a separate layer that squeezes the bytes further during transfer using general-purpose algorithms, and the browser transparently decompresses them on arrival. The two are complementary: you minify then compress, and each contributes savings.
Bundling is different again: it combines many separate source files into one (or a few), reducing the number of network requests a browser must make. Modern build tools like Vite, webpack, and esbuild do all three — bundle your files, minify the result, and let the server compress it — which is why they can turn a sprawling source project into a handful of tiny, fast-loading assets. Understanding that these are separate steps helps you reason about where your file-size savings actually come from.
Why File Size Matters for Performance
Every byte you send has to travel the network and be parsed by the browser, and on slower connections or mobile devices that time adds up quickly. Smaller files mean faster downloads, which translates directly into quicker page loads — and page speed is not just a nicety. It affects user experience (people abandon slow pages), conversion rates, and search ranking, since Google's Core Web Vitals explicitly reward fast-loading pages. JavaScript in particular carries a double cost: it must be downloaded and parsed and executed, so trimming its size speeds up both stages.
The savings are meaningful. Minification alone typically shrinks CSS and JavaScript by 20–40%, and combined with gzip or Brotli compression the total reduction against the original source often reaches 70–90%. For a large application shipping hundreds of kilobytes of code, that is the difference between a snappy first load and a sluggish one, especially for visitors on phones.
When to Use This Tool vs a Build Step
For any real project, minification should be part of your automated build pipeline, not a manual step. Tools like Terser (for JavaScript) and cssnano (for CSS) integrate into webpack, Vite, and similar bundlers, minifying every file on each build using safe, AST-aware parsing that understands the code's structure. This is more reliable than text-based stripping and means you never forget to do it or accidentally ship unminified code.
An online minifier like this one shines for the quick, one-off jobs that do not justify a build setup: shrinking a third-party stylesheet you cannot rebuild, trimming an HTML email template to stay under a client's size limit, reducing a config file, or just checking how much a file could shrink. Because it runs entirely in your browser with nothing uploaded, it is also safe for proprietary code. Keep one habit in mind whichever route you take: always preserve your original, readable source in version control and treat the minified output as a disposable build artifact — minified code is for machines to run, not for humans to edit.
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.