HTML Minifier
NEWMinify HTML in your browser: remove comments and extra whitespace, keep pre, textarea and script content intact, and see the bytes saved.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
What is kept exactly: the content of <pre>, <textarea>, <script> and <title>, attribute quotes and values (only whitespace around a few attributes such as class is trimmed), and the single space between inline elements such as links and spans.
Whitespace modes: safe mode removes spaces next to block elements such as div, p and li. If your CSS turns those into inline-blocks, use conservative mode. Aggressive mode also removes the space between inline elements and text, which can join words. The HTML is parsed as text, never executed.
Quick Examples
Typical inputs and the results this tool produces.
Overview
The HTML minifier shrinks a page by removing what browsers do not need: comments, indentation, line breaks and repeated spaces. Smaller HTML means fewer bytes to download, which helps page speed.
It reads the markup with a tokenizer rather than a pattern replace, so the content of pre, textarea, script and title stays exactly as written and attribute quotes are never removed. A single space between inline elements such as links and spans is kept, so buttons and menus do not collapse into each other.
Options let you keep conditional and Knockout comments, minify inline CSS, trim class attributes and choose safe, conservative or aggressive whitespace. The result shows the size before and after, and everything runs in your browser.
Why use this tool?
- Cut page size before deploying static HTML
- Inline spaces and pre content stay intact
- See bytes and percent saved immediately
- Nothing is uploaded, code stays in your browser
- Free, no sign-up
Features
Whitespace collapse
Removes indentation and line breaks and keeps one space where text needs it.
Comment control
Removes comments but can keep IE conditional comments and Knockout <!-- ko --> comments.
Protected content
The content of pre, textarea, script and title is copied exactly as written.
Inline CSS
Minifies style elements and style attributes by removing comments and extra spaces.
Three whitespace modes
Safe, conservative (keep one space) or aggressive (drop it between all tags).
Size report
Shows original and minified bytes, bytes saved and the percentage, then copy or download the file.
How to Use
Add your HTML
Paste the markup, use Upload file, or press Load sample.
Choose a whitespace mode
Keep Safe for most pages, or use Conservative if your CSS changes how block elements display.
Check the options
Decide which comments to keep, whether to minify inline CSS and whether to trim attribute whitespace.
Copy or download
Read the size report, then press Copy or Download .html.