HTML Minifier
Paste HTML to compress it instantly. The minifier removes comments and collapses needless whitespace while leaving pre, textarea, script and style content untouched, then shows how many bytes you saved.
How to minify HTML
- Paste or type your HTML into the input box.
- Read the minified markup and the size saved in the badge above the output.
- Copy the result or download it as an .html file.
Examples
Strip comments and whitespace
<!-- nav --> <div class="box"> <p>Hello world</p> </div>
<div class="box"><p>Hello world</p></div>
Frequently asked questions
Is my HTML sent to a server?
No. Minification runs entirely in your browser, so your markup never leaves your device.
How does HTML minification reduce file size?
It deletes comments and collapses repeated spaces, tabs and line breaks, including the whitespace between tags, so the same page ships in fewer bytes.
Will it break my inline scripts, styles or preformatted text?
No. Content inside pre, textarea, script and style tags is preserved exactly, so code, CSS and whitespace-sensitive blocks stay intact.
Are IE conditional comments kept?
Yes. Conditional comments such as the if lt IE 9 block are functional, so they are detected and left in place while ordinary comments are removed.
Does minifying HTML change how the page looks?
It should not. Only insignificant whitespace and comments are removed, so the rendered output stays the same in the browser.
Related tools
HTML Entity Encoder
Encode text to HTML entities online. Escape &, <, >, " and ' so markup renders safely, with an option to convert non-ASCII characters too. Free and private.
JSON Formatter
Format, validate and minify JSON online. Pretty-print with custom indentation, sort keys and catch syntax errors. Runs in your browser.
HTML to JSX
Convert HTML to JSX for React. Rename class and for, camelCase attributes and events, turn inline styles into objects and self-close void tags.
Markdown to HTML
Convert Markdown to clean HTML in your browser. Headings, bold, italic, links, images, lists, blockquotes and fenced code blocks, with text safely escaped.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
Aspect Ratio Calculator
Calculate aspect ratios fast. Enter a ratio like 16:9 and one dimension to get the other, or enter width and height to simplify the ratio.