Minify HTML
Minify HTML pages and templates output right here: the tool runs html-minifier-terser in your browser, collapses whitespace, removes comments and redundant type attributes and minifies inline CSS and JavaScript. You see the size before and after, including gzip.
Your code is processed only in your browser and never uploaded.
From the Solo plan
Measure page weight and server response every day
Whether smaller HTML and compression pay off shows in the daily measurement of a plan: page weight, TTFB and LCP per URL over time, with an email when a metric gets worse.
Minify HTML with html-minifier-terser: whitespace, comments and type attributes
html-minifier-terser parses the document and writes it back without what the browser does not need: line breaks and indentation between tags, HTML comments, type="text/javascript" on scripts and type="text/css" on styles. Whitespace is collapsed conservatively, so one space stays where it separates inline elements and the layout does not change. The content of pre and textarea is left alone. Attributes such as type="text" on inputs stay, because CSS selectors like input[type="text"] depend on them.
Comments that frameworks need at runtime, such as Knockout bindings or hydration markers, are kept; wrap other parts that must stay untouched in <!-- htmlmin:ignore -->.
Minify HTML saves less after gzip: 9 percent raw, 4 percent compressed
Measured with this tool's default settings on 27.11.2026 on the perfdelta.com homepage: 141,119 bytes became 128,077 bytes, 9 percent less. Compressed with gzip at level 6 the page went from 27,000 to 25,840 bytes, 4 percent less. The reason: indentation and repeated markup compress very well, so gzip had already removed most of what minification removes.
For HTML, server compression therefore matters more than minification. How to check and enable it is covered in the guide enable text compression.
Minify HTML with inline CSS and JavaScript in one pass
With "Minify inline CSS and JavaScript" the content of style elements and attributes goes through csso and the content of script elements through terser. That pays off on pages with a lot of inline code, such as critical CSS in the head or tracking snippets. CSS that csso cannot read, for example native CSS nesting, stays unchanged and the tool says so. JSON-LD and other script types that are not JavaScript stay unchanged as well.
HTML minify errors: broken attributes and cut-off tags stop the run
If the parser cannot read the markup, for example because an attribute is missing its closing quote or a tag is cut off, the tool stops and shows the line where reading failed. Unclosed elements are completed, as a browser would do. Inline scripts with syntax errors are left unminified. Template syntax such as PHP, Twig or Liquid placeholders is not HTML; minify the rendered page instead of the template.
Minify HTML on the server for pages that are generated per request
CMS and shop pages are created on every request, so minifying a copy by hand does not help them. Many caching plugins and build tools minify the output on the server. Lighthouse checks CSS and JavaScript for minification, not HTML; the guide on minify CSS and JavaScript explains that check.
Other minifiers
Minify HTML FAQ: upload, layout and rankings
Is my HTML uploaded?
No. html-minifier-terser runs in a web worker in your browser. The markup is never sent to a server.
Can minified HTML look different?
With the default settings it should not: whitespace is collapsed to a single space instead of being removed, pre and textarea stay untouched, and attributes that CSS selectors may use are kept. Compare the page before you replace the original.
Does minified HTML improve rankings?
Google does not rank pages by HTML size. A smaller document loads a little faster; in our homepage example the gain after gzip was 4 percent of the transferred bytes.
How large can the HTML be?
Up to 10 MB, pasted or as a file. Very long documents with a lot of inline code take a few seconds.
More free tools
- Webfont Generator: Turns TTF, OTF and WOFF into WOFF2 web fonts with an optional Latin subset and ready @font-face code, or WOFF2 back into TTF. Fonts never leave your device.
- Website Speed Test: Tests several pages of a site on mobile and desktop and shows real-user data, lab findings and competitors in one report.
- Image Compressor: Compresses and converts JPG, PNG, WebP and AVIF in bulk, with responsive sizes and srcset code. Images never leave your device.
- Redirect Checker: Follows a URL hop by hop with status code and milliseconds, and checks that http, https, www and non-www end up at one address.
- HAR Analyzer: Reads a HAR file from DevTools in your browser: waterfall, slow requests, large files, third parties, compression and cache headers.
- Hosting Checker: Finds the host, CDN, server country and CMS of a site and places its real-user server response among other sites at the same host.
Third-party licenses
The minifiers use terser (BSD-2-Clause), html-minifier-terser (MIT) and csso (MIT), also for inline CSS. Full license texts: THIRD_PARTY_LICENSES.txt
A free account saves your tests and shows how your values change from one test to the next. Website performance monitoring with field data and alerts starts with the Solo plan.