HTML Minifier
Minify HTML.
Loading tool…
About this tool
Paste HTML and get a version with the gaps between tags removed and repeated whitespace collapsed to a single space. Comments are removed (except IE conditional comments). It is a simple minifier and does not touch attributes or the contents of scripts, styles, pre and textarea.
How to use
1
Step 1
Paste your HTML.
2
Step 2
Press Run.
3
Step 3
Copy the minified HTML and preview it before shipping.
How it works
Whitespace between a closing > and the next < is removed, then any remaining run of whitespace becomes one space. Comments are kept, and no attribute quotes or optional tags are removed.
Worked example
A list and a paragraph
- Input
- <ul> <li>One</li> <li>Two</li> </ul> <p> Hello world </p>
- Output
- <ul><li>One</li><li>Two</li></ul><p> Hello world </p>
- Walkthrough
- The line breaks and indentation between tags are gone, and the three spaces between Hello and world become one.
Limitations
- The contents of <pre>, <textarea>, <script> and <style> are kept exactly as written.
- Removing the space between inline elements can join words that were separated only by a line break.
- HTML comments are removed, except IE conditional comments.
Questions
How do I minify HTML?
Paste the HTML and press Run to collapse the whitespace.
Is it safe for <pre> blocks?
Yes. The contents of <pre>, <textarea>, <script> and <style> are left exactly as written.
Does it remove comments?
No, only whitespace is changed.
Does it minify inline CSS and JavaScript?
No. Use the CSS minifier for styles.
Features
- Whitespace collapsing
- Tag gaps removed
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
What Is A RESTful API?
Traversy Media
API context for JWT, JSON, and encoding utilities.
Watch on YouTubeHow base64 encoding works
Andrew Schmelyun
Mental model for Base64 encode/decode tools.
Watch on YouTube