Output appears here...How to use
Paste or upload your HTML
Drop a page, template or snippet into the Input pane, or click Upload .html. Try sample loads a page with a comment, a style block, JSON-LD, a script and extra spaces.
Pick options and click Minify
Tick the steps you want, from Remove comments to Remove attribute quotes where safe. Click Minify, or turn on Live mode. The line under the panes shows the size before and after, the percent saved and a gzip estimate.
Copy or download the result
Click Copy, or Download to save a .min.html file. If a script cannot be parsed, a notice says so and that script is left unchanged. Beautify instead reformats the input when you need to read it.
Why HTML Minifier
- Minifies inline CSS, JavaScript and JSON-LD in the same pass.
- Keeps pre, code and textarea content and the visible space between inline elements.
- Optional attribute tidying: boolean attributes, type attributes, empty attributes and quotes.
- Shows bytes before and after with a gzip estimate, all in your browser.
What the HTML minifier removes and keeps
The goal is output that renders the same as the input, which rules out some aggressive tricks and explains why a few spaces survive.
Here is a worked example with the sample page. The comment disappears, the head and body tags sit next to each other, Order #1042 becomes Order #1042, and the space before the strong tag in the paragraph is kept. With the default options, the style block becomes h1{color:#333;margin:0}, the JSON-LD block becomes one line, the greet function is shortened by Terser, and the pre block keeps its spacing.
| Content | What happens |
|---|---|
| Comments | Removed (untick Remove comments to keep them) |
| Conditional comments starting with [if | Kept |
| Runs of spaces, tabs and line breaks | Collapsed to one space |
| Whitespace next to block tags (div, p, li, table, h1 to h6 and similar) | Removed |
| The space between text and inline tags (a, strong, span, img) | Kept as one space |
| pre, code and textarea content | Left exactly as written |
| style blocks and style attributes | Minified with Minify inline CSS |
| script blocks and JSON-LD | Minified with Minify inline JavaScript and JSON-LD; other script types kept |
| Boolean attributes, type attributes, empty attributes, quotes | Changed only when you tick those options |
| Optional closing tags | Left in place |