HTML Compressor
Paste your HTML code below to compress and minify it.
Original HTML
Compressed HTML
Compression Options
How to use HTML Compressor
- 1
Paste your HTML
Copy your page source or HTML snippet into the Original HTML box.
- 2
Choose what to strip
Tick the compression options you want, such as removing comments, collapsing whitespace, dropping empty attributes, or minifying inline CSS and JavaScript.
- 3
Compress the code
Click Compress HTML to minify the markup and see the original size, compressed size, and percentage saved.
- 4
Copy the minified HTML
Use Copy Compressed HTML to grab the optimized code for your site or build pipeline.
Frequently asked questions
What does the HTML compressor remove?
Depending on the options you enable, it strips HTML comments, collapses unnecessary whitespace and newlines, removes empty and optional attributes, collapses boolean attributes, and can drop optional closing tags to shrink file size.
Can it minify inline CSS and JavaScript too?
Yes. There are experimental options to minify CSS inside <style> tags and style attributes, and to minify JavaScript inside <script> tags, so you can compress an entire page in one pass.
How much smaller will my file get?
It depends on how much whitespace and comments your markup contains, but the tool shows the exact original size, compressed size, and reduction percentage so you can see the bytes saved for your specific file.
Will minifying break my page?
Standard whitespace and comment removal is safe for well-formed HTML. The CSS and JS minification options are marked experimental, so it is wise to test the output, especially if your scripts rely on specific formatting or comments.
Is my HTML uploaded to a server?
No. Compression runs entirely in your browser, so your code stays on your device. The tool is free, requires no sign-up, and works on mobile.
Related tools
Keep going with these handy tools