Smaller payloads, faster first paint
Removing indentation and line breaks typically cuts a hand-written template by a third or more before compression, which matters most on large pages and slow connections.
Strip whitespace and comments from HTML to shrink the file with this HTML minifier.
Loading tool…
The tool is loading its code on your device. This happens once and is cached for later visits.
Processed entirely on your device
Overview
Minify HTML online — remove indentation, line breaks and comments to cut transfer size, and see the exact byte saving. Everything runs in your browser, nothing is uploaded.
An HTML minifier is the last step before markup meets the network: same document, fewer bytes, identical rendering. It sits at the end of a build for the same reason compilation does — the human-readable source is for people, and the shippable artefact is for machines. When you minify HTML, the indentation, newlines and comments that make source readable are stripped, and the page a browser paints is unchanged.
This free HTML minifier runs in your browser and shows the exact byte saving: paste the formatted markup, press the button, compare before and after, then copy or download the compressed result. Nothing is uploaded at any point.
Whitespace between tags is the main target: the indentation, the newlines between elements and the runs of spaces that make source readable. HTML comments are dropped too, since they are never rendered. None of this changes what the browser paints, because the rendering engine already collapses inter-element whitespace to a single space.
Whitespace is content in a few places, and removing it there is a real bug:
A minifier that does not understand these contexts will quietly reflow code samples and preformatted blocks. This one leaves them intact.
If your HTML travels over HTTPS with gzip or Brotli enabled — and it almost certainly does — minification saves less than the raw byte count suggests. Indentation is repetitive, and repetition is exactly what those algorithms compress best. The two together usually beat either alone, but the marginal gain from minifying on top of compression is smaller than the character count implies.
It still matters when the markup is stored uncompressed, embedded in a length-limited field, served over a protocol that cannot compress, or delivered at a volume where a few percent of bandwidth is worth capturing.
The right place for this is a build step that reads your formatted source and writes a compressed artefact. Doing it by hand in an editor means the next person cannot read the file they have to maintain. Keep source pretty, ship it small.
For a hand-indented document, usually 20 to 40 percent; deeply nested templates with four-space indentation save more. Comments are often the single biggest win on heavily annotated markup, since a paragraph of notes is pure transfer cost. Once gzip or Brotli is applied in transit the marginal gain shrinks — repeated indentation compresses extremely well — but minified plus compressed remains the smallest option, and for stored or embedded markup there is no compression to lean on.
Not every byte of HTML travels over a compressed connection. Email bodies, iframe embeds, server-rendered fragments pasted into length-limited fields, and offline HTML bundled into apps or devices all ship raw. That is where an HTML minifier pays for itself without qualification: the saving is not partially eaten by transport compression because there is no transport compression. A landing page squeezed under a size budget, or an email that renders faster in a client that counts every kilobyte, is a direct win.
They are usually minified together in a build pipeline, and this family of tools covers each separately: minify HTML for the markup, run the stylesheet through the CSS minifier, and the scripts through the JavaScript minifier. Keeping them separate is deliberate — each language has different whitespace rules and different failure modes, and a tool that understands only one language can be conservative and safe in the way a combined preprocessor rarely is.
The whole pass — comment removal, whitespace collapse, the safety checks around pre and textarea — happens in your tab. That is the right default for markup that carries unpublished structure, analytics snippets and internal URLs: minifying it should not mean pasting it into a stranger's form. Paste, minify, check the byte counter, copy or download. Private, instant, free, and safe to run on the one template you would least want a third party to see.
The byte counter doubles as a diagnostic. If minifying saves almost nothing, the weight is in the content — images, inline data URIs, inline styles and scripts — and no whitespace removal will help. If it saves a lot, formatting was the problem and the fix is free. Running that check before reaching for heavier optimisation saves an afternoon of work on the wrong bottleneck.
Step by step
Paste the formatted HTML you want to compress.
Press Minify HTML; comments and insignificant whitespace are removed.
Compare the input and output byte counts to see the saving.
Copy the minified markup or download it as an .html file.
Why use it
What this tool is good for, and what it deliberately does not try to do.
Removing indentation and line breaks typically cuts a hand-written template by a third or more before compression, which matters most on large pages and slow connections.
Only whitespace the browser would collapse anyway is removed, and sensitive contexts such as pre and textarea are left intact so the page still looks identical.
Reports the character count before and after so you can judge whether minification is worth it for a given document.
Unpublished markup and tracking snippets never leave your machine — the minifier is pure client-side JavaScript.
Questions
Short, honest answers about quality, limits and privacy.