How to use it
- Paste your HTML, or open an .html file.
- Leave Language on HTML and the action on Minify (preselected here).
- Tick or untick Remove comments and Shorten local variable names.
- Copy the result or download minified.min.html.
Worked example
A list with two items on indented lines, a comment and <p>Hello world</p> (75 bytes) becomes <ul><li>One</li><li>Two</li></ul><p>Hello world</p>, which is 51 bytes.
Formats and limits
| Input | HTML |
|---|---|
| Output | Minified HTML |
| Engine | Prettier standalone; Terser; CSSO; HTML whitespace/comment minifier with embedded CSS/JS minification |
Limitations
- Tags, attribute values and entity references are kept as written; only whitespace, comments and inline code get smaller.
- Whitespace next to block elements is removed on the assumption of default CSS; check pages that change display with CSS.
- Script blocks of other types than JavaScript and JSON are kept as written.
Questions
Which whitespace is removed?
Runs of spaces and line breaks in text become one space, and whitespace next to block elements such as div, p and li is removed. Text inside pre and textarea is left exactly as written.
Are comments removed?
Yes, while Remove comments is ticked. Internet Explorer conditional comments such as <!--[if IE]> are always kept.
What if an inline script has an error?
That block is kept as written and a warning names the problem, with the line inside the script. The rest of the page is still minified.
Is my HTML uploaded?
No. The code is processed in your browser and nothing is uploaded.
Privacy
Runs on your device. Files and text are processed in this browser tab and are not uploaded.
This page opens the Code formatter and minifier ready for this task. See the privacy policy for how toolsdocks handles data.