HTML Minifier
Minify and compress HTML code instantly in your browser. Remove comments, collapse whitespace, and reduce file size. Free and private.
Drag & Drop an HTML file here
Supports .html and .htm files. Or paste your HTML above.
Minify and compress HTML code instantly in your browser. Remove comments, collapse whitespace, and reduce file size. Free and private.
Supports .html and .htm files. Or paste your HTML above.
HTML minification strips unnecessary characters from a webpage's source — whitespace between tags, comments, redundant quotes, optional closing tags — to reduce file size without changing how the page renders. The savings are modest per page (typically 10–30%) but compound across many requests, particularly for static sites or pages served without dynamic compression.
This minifier removes whitespace between block-level elements, collapses runs of whitespace inside non-significant text, strips HTML comments (except IE conditional comments), removes redundant attribute quotes where allowed by the HTML5 spec, and elides optional closing tags (</p>, </li>) where the spec permits. The result renders identically to the source in every browser.
Minification is most useful when paired with gzip or Brotli compression at the server level. Compression already removes much of the savings minification produces, but the two combined still beat compression alone — particularly for high-traffic sites where bandwidth costs matter.
Smaller HTML loads faster, especially on slower connections and mobile networks. Page weight directly affects Core Web Vitals — Largest Contentful Paint and Time to First Byte both improve when the server returns less HTML to parse. For sites where SEO ranking depends on Core Web Vitals scores, minification is a measurable improvement.
Minified HTML also reduces bandwidth costs at scale. A site serving a million pages a day with 10 KB savings per page saves 10 GB of egress daily. The impact compounds for static sites served from CDNs that bill by data transfer.
Paste HTML, get the minified version.
The minifier processes HTML token by token. Whitespace between block-level elements (<div>, <p>, <ul>) is removed because it does not affect rendering. Whitespace inside inline contexts (<span>, <a>, text content) is preserved because it can affect rendering.
Comments are stripped by default but conditional comments (<!--[if IE]>) are preserved. Attribute quotes are removed where the HTML5 parser allows — single-word attribute values without spaces or special characters can omit quotes.
Optional closing tags are elided per the HTML5 spec: </p>, </li>, </td>, and a few others can be omitted when followed by a sibling that implies their close. This is unusual to read but valid HTML5 that browsers parse identically.