HTML Minifier
Minify HTML by removing comments and collapsing whitespace while preserving pre, textarea, script and style blocks.
About the HTML Minifier
The HTML Minifier shrinks pages by removing comments and collapsing whitespace, while leaving <pre>, <textarea>, <script> and <style> blocks untouched so nothing breaks.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the HTML Minifier
- Paste HTML or open a file.
- Choose whether to remove comments.
- Copy or download the minified markup.
Frequently asked questions
Why are <pre> and <textarea> left alone?
Whitespace inside them is displayed to the user, so collapsing it would change the page.
Can I keep comments?
Yes. Switch off "Remove comments" to keep them, for example licence notices.
Related tools
JSON Minifier
Minify JSON by removing all unnecessary whitespace. Shows the size saved.
CSS Minifier
Minify CSS by stripping comments and whitespace to reduce stylesheet size.
JavaScript Minifier
Minify and mangle JavaScript with Terser for smaller bundles. Supports modern ES syntax.
XML Minifier
Minify XML by removing comments and whitespace between tags.
SQL Minifier
Compress SQL queries onto a single line, removing comments and redundant whitespace.
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.