HTML Minifier
Compact HTML tag syntax and ordinary comments locally while preserving text whitespace, embedded code and sensitive contexts.
Your HTML
Up to 256 KiB measured as UTF-8. Processing runs in a disposable local Web Worker.
Parse5 normalizes shorter start tags and removes ordinary comments. Visible text whitespace, sensitive content and framework markers are preserved. Embedded scripts are never executed or minified. This conservative mode does not sanitize HTML. Libraries load from this site only when you run the tool.
Minified output
Understand your results
For developers reducing avoidable HTML syntax overhead in a reviewed document.
A local worker parses HTML with parse5 and edits source locations. It shortens start tags when serialization is smaller and removes ordinary comments. Visible text whitespace and sensitive regions remain verbatim. Scripts are never executed, and embedded JavaScript or CSS is left intact.
How to use this tool
- Paste HTML or choose a UTF-8 .html or .htm file up to 256 KiB.
- Run Minify HTML and review measured UTF-8 sizes and the output.
- Copy or download the result and compare the rendered page in its intended application.
What the observations mean
The size figures measure UTF-8 bytes before transport compression. Tag normalization can produce no savings when the source is already compact.
Worked example
Shorten start-tag syntax while preserving text spacing.
<div class = "card" > Hello <span>world</span></div><!-- ordinary note -->The div start tag becomes <div class="card"> and the ordinary comment is removed. The two spaces before Hello and the inline space before span stay intact.
Limits and processing
Up to 256 KiB UTF-8, 10,000 parsed nodes and 128 levels, with a 12-second worker deadline. Conditional, license and recognizable framework comments are retained. This tool does not sanitize HTML or minify embedded code.
Common problems and practical fixes
- A parse error blocks processing
- Fix the reported HTML syntax issue first. The tool does not silently rewrite a malformed tree.
- The output barely shrinks
- Most text whitespace is meaningful without the final CSS context, so this mode preserves it.
- A large document is rejected
- Keep the source within 256 KiB, 10,000 parsed nodes and 128 levels.
Best practices
Treat the result as a reviewed build artifact. Test scripts, styling and template behavior in the destination before replacing source files.
Practical tips
- Keep the original source and compare a representative rendered page.
- Use the separate CSS and JavaScript minifiers for those languages.
Frequently asked questions
Practical answers for using the HTML Minifier.
Will it collapse spaces between inline elements?
No. Text-node whitespace is kept so layouts that depend on inline spacing remain stable.
What happens inside pre, textarea or script?
Those sensitive regions are preserved. The tool also keeps templates, style, code and foreign SVG/MathML regions.
Can it format HTML?
This tool provides conservative minification only. Its source-location strategy does not provide a pretty-print mode.