HTML Minifier
Strip comments and extra whitespace from HTML.
- 100% Free
- No Sign Up
- Works in Your Browser
HTML minifier
Compress HTML by removing whitespace
Everything runs in your browser. Nothing is uploaded.
More Developer Tools
View all tools- JSON formatterPretty-print and indent JSON
- JSON validatorCheck JSON and find syntax errors
- JSON minifierStrip whitespace from JSON
- XML formatterIndent XML so it's readable
- SQL formatterFormat SQL queries for readability
- Base64 encode/decodeEncode and decode Base64 text
- JWT decoderDecode a JSON Web Token
- UUID generatorGenerate random v4 or time-ordered v7 UUIDs
- Timestamp converterConvert Unix epoch time to dates
Every everyday developer tool, right in your browser.
No installs. No uploads. No signup.
Browse all 36 tools- Developer tools
- 36
- Cheat sheets
- 10
- Bytes uploaded
- 0
How to use the HTML minifier
Three steps, all in your browser.
- 1
Paste your input
Type or paste your code or data. Press Sample to try an example.
- 2
Pick the style
Choose indentation or options. The result updates as you type.
- 3
Copy the result
Copy the output in one click. Nothing is saved or sent anywhere.
HTML Minifier: what to know
The HTML minifier removes comments and the whitespace between tags where it's safe. It tokenizes the document rather than using regular expressions, so attribute values are never changed, and the content of <pre> and <textarea> elements, where whitespace is visible, is left exactly as it was. Inline <style> and <script> blocks are kept as they are unless you choose to minify them too.
HTML is whitespace-sensitive between inline elements: two links separated by a line break render with a space between them. That's why whitespace next to block elements such as <div> and <p> is removed, while whitespace between inline elements is collapsed to a single space, so the page should look the same before and after.
Conditional comments for old Internet Explorer versions (<!--[if IE]>) and comments that start with <!--! are kept, since some pages still rely on them. Everything else between <!-- and --> is removed.
Popular uses
- Shrinking static HTML pages without a build step
- Compacting HTML email templates
- Minifying HTML snippets stored in a database or CMS
- Checking how much of a page's size is whitespace
Tips for the best result
- Minify the output, not the template you edit: keep a readable source.
- Compare the page visually after minifying, especially around inline elements and buttons placed side by side.
- Use the HTML formatter to reverse the process when you need to read minified markup.
Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.