HTML Minifier
Paste HTML above to minify it.
Paste your HTML and get a smaller version instantly. This tool removes comments and collapses runs of whitespace between tags, while preserving the exact contents of pre, textarea, script, and style blocks so your code and preformatted text stay correct. Everything runs in your browser, so nothing is uploaded.
How to use
- Paste or type your HTML into the input box on the left.
- The minified result appears on the right as you type.
- Check the status line to see how many characters you saved.
- Click Copy to copy the minified HTML, or Reset to start over.
Examples
- Input: <div> <!-- note --> <p>Hi</p> </div> Output: <div><p>Hi</p></div>
- Input: <p>Hello world</p> Output: <p>Hello world</p>
- Input with a pre block: <pre> line one\n line two </pre> stays exactly as written.
FAQs
- Does this change the contents of script and style tags?
- No. The contents of script, style, pre, and textarea blocks are preserved exactly. Only the HTML around them is minified.
- Does it remove all comments?
- Yes. It strips every HTML comment, including downlevel conditional comments. If you rely on conditional comments, keep an unminified copy.
- Will minifying break my whitespace sensitive layout?
- Whitespace between tags is removed, which can affect inline elements that depend on a space between them. Preformatted content inside pre and textarea is kept intact.
- Is my HTML uploaded anywhere?
- No. All processing happens locally in your browser, so your HTML never leaves your device.
- How much smaller will my file get?
- It depends on how much whitespace and how many comments your HTML contains. The status line shows the exact character count and percentage saved for your input.
Related tools
- CSS MinifierMinify CSS online. Strip comments and whitespace, collapse spaces, and shrink stylesheets while keeping strings and url() values intact.
- XML FormatterPretty print XML with clean indentation per nesting level. Pick 2 spaces, 4 spaces, or tabs. Validates broken markup, runs in your browser.
- Diff CheckerCompare two blocks of text and see what changed, line by line or word by word. Side by side, inline, or unified diff views. Free and private in your browser.
- String EscaperEscape and unescape strings for JSON and JavaScript. Convert newlines, tabs, quotes, and backslashes to and from their escaped forms in your browser.
- JSON FormatterFormat, validate, and beautify JSON in your browser. Paste messy JSON, get clean indented output, then copy it back. Free, no signup.
- Base64 EncoderEncode text to Base64 or decode Base64 back to text in your browser. Full UTF-8 support and clear errors on invalid input.