HTML Minifier
About this tool
About HTML Minifier
Shrink an HTML page, an email template or a component before you ship it. The minifier removes comments, collapses every run of spaces, tabs and line breaks into a single space, and tidies the whitespace inside tags between attributes, without touching attribute values. With the inline option on, the CSS inside <style> blocks and the JavaScript inside <script> blocks is minified too, and JSON-LD structured data is compacted. Content where whitespace matters is left exactly as written: <pre> and <textarea> blocks, and scripts with an unknown type such as text/template. IE conditional comments are kept. You can also remove the whitespace between tags entirely for the smallest result, which is optional because it can join two inline elements, such as adjacent links, that were separated only by a space. The output size and the percentage saved are shown. Everything runs in your browser and nothing is uploaded.
Built and maintained by Abhi JainUpdated
How to Minify HTML
- 1
Paste or open HTML
Paste HTML into the left pane or open an .html file.
- 2
Choose the options
Keep Minify inline <style> and <script> on, and turn on Remove spaces between tags if you want the smallest output.
- 3
Copy or download
Check the saving shown under the panes, then copy or download the minified HTML.
HTML Minifier: questions and answers
Is minifying HTML worth it?
The saving depends on how many comments and how much indentation the page has, and the tool shows it exactly. Gzip or Brotli on the server saves far more, but minifying first still helps, especially for pages with many comments or deeply indented markup.
Can minifying HTML break my page?
Collapsing whitespace is safe for normal text. Removing all whitespace between tags can join inline elements visually, which is why that option is off by default. Content in <pre> and <textarea> is never changed.
Does it minify CSS and JavaScript inside the page?
Yes, when Minify inline <style> and <script> is on. The JavaScript minifier is conservative: it removes comments and whitespace but does not rename variables.
Is my HTML uploaded?
No. Minification runs entirely in your browser.
More HTML Formatter presets
Related tools
- CSS FormatterBeautify minified CSS into readable rules, or minify it safely.
- JavaScript FormatterBeautify minified JavaScript, or minify it safely by removing comments and whitespace.
- HTML, CSS & JS PlaygroundWrite HTML, CSS and JavaScript and see a live, sandboxed preview with a console.
- HTML to PDFTurn HTML into a PDF with your browser's print engine: page size, margins, no upload.
- XML FormatterPretty-print, minify and validate XML with line and column errors.