Minify HTML, CSS & JavaScript Code
Minify HTML, CSS, and JavaScript by removing comments and whitespace to shrink file size.
- No upload
- No signup
- Free
Loading tool…
Your file stays in this browser. Nothing is uploaded.
Loading tool…
Your file stays in this browser. Nothing is uploaded.
How HTML / CSS / JS Code Minifier works
Browser Toolset Code Minifier shrinks HTML markup, CSS stylesheets, and JavaScript code client-side. It strips comments and collapses whitespace to reduce payload bytes, with zero server uploads. It does not rename variables or rewrite your code.
How to use this tool
- Select your programming language mode (HTML, CSS, or JS).
- Paste your source code into the editor.
- View real-time byte savings and percentage reduction statistics.
- Review the clean, minified output code in the preview pane.
- Click "Copy Minified" to copy the optimized payload to clipboard.
Common uses
- Web developers shrinking assets before deploying to hosting.
- Email developers shrinking HTML template sizes, for example to stay under Gmail clipping limits.
- Engineers preparing compact inline SVG or CSS snippets for fast initial paint.
- Blogger and WordPress publishers compressing custom CSS tweaks.
Frequently asked questions
How does minification improve website performance?
Minification removes comments and unneeded whitespace, so the file is smaller to download and the browser can fetch it faster. The gain is biggest for CSS and HTML with many comments, and the Saved percentage shows your own result.
Is my proprietary source code sent to any external server?
No. Minification runs in your browser and the code you paste is not uploaded. The tool does not save it, but it stays on the page until you clear or reload it, so remove it on shared computers.
Does minifying break code functionality?
It usually does not, because the tool only removes comments and whitespace. But the CSS and HTML modes use simple text rules rather than a full parser, so edge cases can change the output (for example, spacing between inline HTML tags or unusual CSS selectors). Test the minified result before deploying.
Can I see how many bytes were saved?
Yes. The toolbar shows the original size and the minified size in bytes, measured as UTF-8, plus a Saved percentage. They update as you edit the input or switch between CSS, HTML and JS.
Does it support modern CSS variables and HTML5 syntax?
Generally yes. It only strips comments and whitespace, so CSS custom properties and HTML5 tags pass through unchanged. Because it is not a full CSS or HTML parser, check unusual syntax in the output.
Details and limits
Extra whitespace in stylesheets and scripts adds to download size. Our in-browser Code Minifier strips comments and whitespace from HTML, CSS, and JS so you can ship leaner web assets without leaking proprietary code to third parties.
What each language mode removes
The code is processed in your browser and nothing is uploaded. Choose CSS (the default), HTML or JS, and the minified version appears as you type next to a count of original bytes, minified bytes and the percentage saved. No variables are renamed and no code is rewritten, so the saving comes from comments and whitespace only.
CSS mode is simple text replacement. It deletes comments, collapses whitespace and strips spaces around braces, colons, semicolons and commas. JS mode reads the code token by token. It keeps strings, template literals and regular expressions exactly as written and removes comments and whitespace, but keeps a line break wherever dropping it could change automatic semicolon insertion. HTML mode deletes comments, collapses whitespace and removes whitespace between tags. The contents of pre, textarea, script and style blocks are copied verbatim.
Features and limits
- The byte counts use UTF-8 size, and the saving is rounded and never shown below 0 percent.
- Copy Minified copies the result. There is no download button and no option to beautify.
- Because CSS mode does not parse the code, a space before a colon is removed everywhere. A selector such as ul :first-child becomes ul:first-child, which means something different, and text inside quotes or url() values is also collapsed. Comments inside strings are removed too.
- HTML mode removes the space between two inline elements, as in a bold word followed by an italic word. The page can look slightly different afterwards.
- Inline script and style blocks inside HTML are not minified. Paste their contents in JS or CSS mode separately.
- JS mode does not check syntax or remove dead code. Colour values, trailing semicolons and long names are left as they are, so savings are smaller than a build-step minifier gives.
Testing minified code safely
Keep the original file, and treat minified output as a build artefact you can regenerate. After minifying, load the page or run the script and look for layout changes or console errors. The Text & Code Diff Checker can show exactly what changed between the two versions.
Because this tool is conservative, it suits quick jobs: a snippet for an email template, an inline style, or a custom CSS box in a CMS. For a whole project, use a minifier in your build step, which can also rename variables and merge rules. Related tools are the Vector SVG Optimizer for graphics, the SQL Formatter & Beautifier when you need the opposite direction for queries, and the JSON Formatter & Validator for data.