HTML Minifier
Shrink HTML to its smallest safe form: comments stripped, whitespace collapsed, and blank lines removed — without touching the content of <pre>, <textarea>, <script>, or <style>.
工具摘要
此工具接收结构化输入,在浏览器中返回确定性输出,无需上传到服务器。
- 工具名称
- HTML Minifier
- 输入意图
- 提供需要转换、校验或分析的原始内容。
- 输出意图
- 获得可直接复制、复用或排错的规范化输出。
- 示例输入
- <!DOCTYPE html> <html> <!-- a comment --> <body> <p> hello </p> </body> </html>
- 示例输出
- <!DOCTYPE html><html><body><p> hello </p></body></html>
<pre>, <textarea>, <script>, and <style> is preserved verbatim.工具介绍
Shrink HTML to its smallest safe form: comments stripped, whitespace collapsed, and blank lines removed — without touching the content of <pre>, <textarea>, <script>, or <style>.
工具概览
A minifier reduces the bytes a browser has to download by removing characters that do not affect rendering. Comments, runs of whitespace, and newlines between tags are all safe to strip in most documents. This tool walks your HTML, sets aside the contents of preserved tags (<pre>, <textarea>, <script>, <style>) so they survive intact, then collapses whitespace in the rest. Toggle each option to match your stack — keep IE conditional comments, preserve line breaks for readable diffs, or drop empty class="" attributes. Everything runs locally in your browser; nothing is uploaded.
使用场景
- Trim bytes off email templates, transactional HTML, and AMP fragments before sending.
- Pre-process server-rendered HTML for cache-friendly delivery on edge networks.
- Strip developer comments and indentation from snippets before pasting into a CMS.
输入/输出示例
<!DOCTYPE html>
<html>
<!-- a comment -->
<body>
<p> hello </p>
</body>
</html><!DOCTYPE html><html><body><p> hello </p></body></html>
常见问题
Will it break <pre> or <script> contents?+
Does it remove IE conditional comments?+
Is the output safe to deploy to production?+
Is my HTML uploaded?+
探索更多工具
在下方的 Developer 分类中发现相关工具。
相关工具
精选可能对你有用的实用工具