HTML Minifier
Remove redundant whitespace from HTML markup to produce a leaner, faster payload.
HTML input
Minified output
HTML result
What is HTML minification?
HTML minification removes characters from HTML source that browsers ignore — whitespace between tags, indentation, newlines, and HTML comments — to reduce the total file size sent over the network. The browser renders the minified HTML identically to the original because these characters have no effect on the document tree. Smaller HTML means the browser receives and parses the page faster, which directly improves Time to First Byte (TTFB) and Largest Contentful Paint (LCP) — two Core Web Vitals that affect Google search rankings.
What minification removes
- Inter-tag whitespace: Sequences of spaces, tabs, and newlines between HTML tags are collapsed to a single space or removed entirely
- Leading/trailing whitespace: Indentation at the start of each line and trailing spaces are stripped
- HTML comments:
<!-- comments -->are removed (except conditional comments used for IE compatibility, which are preserved) - Redundant attributes: Boolean attributes like
type="text/javascript"on script tags andtype="text/css"on style tags are removed since they are the default in HTML5
Typical size reduction
HTML minification typically reduces file size by 10–30%. The actual saving depends heavily on how much whitespace and how many comments the original contains. A well-indented HTML file with 4-space indentation and many comment blocks will see larger reductions than a moderately indented file. For most pages, the absolute byte savings from HTML minification are smaller than those from CSS and JavaScript minification — but all three together make a meaningful difference, especially on mobile connections.
Minification in a build pipeline
For production projects, minification belongs in your build or deploy pipeline, not done manually. Tools that handle HTML minification automatically include: webpack's html-webpack-plugin with minify options, Vite's built-in HTML processing, Gulp with gulp-htmlmin, and dotnet publish for ASP.NET Core apps with Bundler and Minifier. The pattern is: keep the readable source in version control, minify as a build step, and never edit the minified output directly.
How to use this tool
- Paste your HTML markup into the input editor.
- Click Minify.
- View the compressed output on the right.
- Copy the minified HTML and use it in your production deployment.
HTTP compression vs minification
Minification and HTTP compression (gzip or Brotli) are complementary, not alternatives. Minification reduces the file size by removing redundant characters from the source. HTTP compression then compresses the already-minified file further using standard compression algorithms before transmission. Most web servers and CDNs apply gzip or Brotli automatically. Applying both gives you the smallest possible payload: minification removes what compression cannot easily spot, and compression handles the repetitive patterns that remain.